From 7379114c2f2c2ec1f767a16cf2f8662ea6bd8db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 11 Apr 2011 18:01:10 +0200 Subject: Remove code duplication. --- activemodel/lib/active_model/validations/exclusion.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activemodel/lib/active_model/validations/exclusion.rb') diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index d135d0164a..a85c23f725 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -9,13 +9,14 @@ module ActiveModel "and must be supplied as the :in option of the configuration hash" def check_validity! - unless [:include?, :call].any?{ |method| options[:in].respond_to?(method) } + unless [:include?, :call].any? { |method| options[:in].respond_to?(method) } raise ArgumentError, ERROR_MESSAGE end end def validate_each(record, attribute, value) - exclusions = options[:in].respond_to?(:call) ? options[:in].call(record) : options[:in] + delimiter = options[:in] + exclusions = delimiter.respond_to?(:call) ? delimiter.call(record) : delimiter if exclusions.send(inclusion_method(exclusions), value) record.errors.add(attribute, :exclusion, options.except(:in).merge!(:value => value)) end -- cgit v1.2.3