From 2476c5312dcbd29f49672f71617a3d34c6a60cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 22 Dec 2009 23:12:21 +0100 Subject: Validator is simply sent to validate method. However, the API needs to change, so validate accepts a record. --- activemodel/lib/active_model/validations/with.rb | 8 +++----- activemodel/lib/active_model/validator.rb | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index edc2133ddc..8313aded11 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -49,12 +49,10 @@ module ActiveModel # end # def validates_with(*args) - configuration = args.extract_options! + options = args.extract_options! - validate configuration do |record| - args.each do |klass| - klass.new(record, configuration.except(:on, :if, :unless)).validate - end + args.each do |klass| + validate klass.new(options.except(:on, :if, :unless)), options end end end diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 09de72b757..80a538fcb6 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -54,14 +54,13 @@ module ActiveModel #:nodoc: # end # class Validator - attr_reader :record, :options + attr_reader :options - def initialize(record, options) - @record = record + def initialize(options) @options = options end - def validate + def validate(record) raise "You must override this method" end end -- cgit v1.2.3