diff options
author | Mingdong Luo <mdluo@nsmss.com> | 2015-01-31 19:23:48 -0800 |
---|---|---|
committer | Mingdong Luo <mdluo@nsmss.com> | 2015-01-31 19:23:48 -0800 |
commit | 549d171a90135999e3c670f489494b7a39dd6dd7 (patch) | |
tree | 233466527b797fe3ea7c6a7a3673795cea28aebe /activerecord/lib/active_record/attribute_set.rb | |
parent | c840b18ac31a852d99ff760229f2c087b6961727 (diff) | |
parent | 70ac072976c8cc6f013f0df3777e54ccae3f4f8c (diff) | |
download | rails-549d171a90135999e3c670f489494b7a39dd6dd7.tar.gz rails-549d171a90135999e3c670f489494b7a39dd6dd7.tar.bz2 rails-549d171a90135999e3c670f489494b7a39dd6dd7.zip |
Merge branch 'master' into pr/18316
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/attribute_set.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_set.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_set.rb b/activerecord/lib/active_record/attribute_set.rb index 66fcaf6945..9142317646 100644 --- a/activerecord/lib/active_record/attribute_set.rb +++ b/activerecord/lib/active_record/attribute_set.rb @@ -10,6 +10,10 @@ module ActiveRecord attributes[name] || Attribute.null(name) end + def []=(name, value) + attributes[name] = value + end + def values_before_type_cast attributes.transform_values(&:value_before_type_cast) end @@ -24,7 +28,7 @@ module ActiveRecord end def keys - attributes.initialized_keys + attributes.each_key.select { |name| self[name].initialized? } end def fetch_value(name) @@ -49,7 +53,7 @@ module ActiveRecord end def initialize_dup(_) - @attributes = attributes.dup + @attributes = attributes.deep_dup super end @@ -64,6 +68,10 @@ module ActiveRecord end end + def accessed + attributes.select { |_, attr| attr.has_been_read? }.keys + end + protected attr_reader :attributes |