From 0ee6aa749cde21dad0e5f394a7feb3173f357d2f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 25 Jun 2012 14:24:46 -0300 Subject: Set hash value instead of merge a single key, and use flatten! if possible There's no need to create two extra hashes with options.merge(another_hash), with the goal of setting only one value, so lets just set it. Also refactor validates_each to use _merge_attributes, like other validates_* helpers do. --- activemodel/lib/active_model/validations.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activemodel/lib/active_model/validations.rb') diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index cd596e37d2..55ea6be796 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -82,8 +82,7 @@ module ActiveModel # :unless => Proc.new { |user| user.signup_step <= 2 }). The # method, proc or string should return or evaluate to a true or false value. def validates_each(*attr_names, &block) - options = attr_names.extract_options!.symbolize_keys - validates_with BlockValidator, options.merge(:attributes => attr_names.flatten), &block + validates_with BlockValidator, _merge_attributes(attr_names), &block end # Adds a validation method or block to the class. This is useful when -- cgit v1.2.3