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/with.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activemodel/lib/active_model/validations') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index 3158f36b6e..3c516f8b22 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -3,8 +3,10 @@ module ActiveModel module HelperMethods private def _merge_attributes(attr_names) - options = attr_names.extract_options! - options.merge(:attributes => attr_names.flatten) + options = attr_names.extract_options!.symbolize_keys + attr_names.flatten! + options[:attributes] = attr_names + options end end -- cgit v1.2.3