diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-02 20:49:19 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-05 09:52:58 +0900 |
commit | 4331478996d6086bb089c1e33956a1c0fa9000b1 (patch) | |
tree | df43ca3a6da0aee240f5c7cf87bcbf35168e1268 /activerecord/lib/active_record/attribute_methods.rb | |
parent | e117d9266e577675afe1462e37601c029e21091b (diff) | |
download | rails-4331478996d6086bb089c1e33956a1c0fa9000b1.tar.gz rails-4331478996d6086bb089c1e33956a1c0fa9000b1.tar.bz2 rails-4331478996d6086bb089c1e33956a1c0fa9000b1.zip |
Refactor `_substitute_values` to be passed attribute names and values
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 842f407517..0ca0e5dcdb 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -438,24 +438,18 @@ module ActiveRecord defined?(@attributes) && @attributes.key?(attr_name) end - def arel_attributes_with_values_for_create(attribute_names) - arel_attributes_with_values(attributes_for_create(attribute_names)) + def attributes_with_values_for_create(attribute_names) + attributes_with_values(attributes_for_create(attribute_names)) end - def arel_attributes_with_values_for_update(attribute_names) - arel_attributes_with_values(attributes_for_update(attribute_names)) + def attributes_with_values_for_update(attribute_names) + attributes_with_values(attributes_for_update(attribute_names)) end - # Returns a Hash of the Arel::Attributes and attribute values that have been - # typecasted for use in an Arel insert/update method. - def arel_attributes_with_values(attribute_names) - attrs = {} - arel_table = self.class.arel_table - - attribute_names.each do |name| - attrs[arel_table[name]] = _read_attribute(name) + def attributes_with_values(attribute_names) + attribute_names.each_with_object({}) do |name, attrs| + attrs[name] = _read_attribute(name) end - attrs end # Filters the primary keys and readonly attributes from the attribute names. |