From 7d84c3a2f7ede0e8d04540e9c0640de7378e9b3a Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Mon, 13 May 2013 13:59:28 +1000 Subject: deprecate Validator#setup (to get rid of a respond_to call). validators do their setup in their constructor now. --- activemodel/lib/active_model/validations/acceptance.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activemodel/lib/active_model/validations/acceptance.rb') diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index 78e6f67a47..139de16326 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -4,6 +4,7 @@ module ActiveModel class AcceptanceValidator < EachValidator # :nodoc: def initialize(options) super({ allow_nil: true, accept: "1" }.merge!(options)) + setup!(options[:class]) end def validate_each(record, attribute, value) @@ -12,7 +13,8 @@ module ActiveModel end end - def setup(klass) + private + def setup!(klass) attr_readers = attributes.reject { |name| klass.attribute_method?(name) } attr_writers = attributes.reject { |name| klass.attribute_method?("#{name}=") } klass.send(:attr_reader, *attr_readers) -- cgit v1.2.3