aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-19 16:14:55 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-19 16:14:55 -0300
commit70de7dda8c09c1e02e0281879ef6fb8f372ada5e (patch)
tree999d08ae19eb59d738909c94287833b7e86824ad /activerecord/lib/active_record/attribute_methods.rb
parentc36e77a93e286f4546a36e79d43f543e9f00d6be (diff)
parent099af48d31bb2b5fc8e3fff39b825efff7964d55 (diff)
downloadrails-70de7dda8c09c1e02e0281879ef6fb8f372ada5e.tar.gz
rails-70de7dda8c09c1e02e0281879ef6fb8f372ada5e.tar.bz2
rails-70de7dda8c09c1e02e0281879ef6fb8f372ada5e.zip
Merge pull request #15818 from sgrif/sg-attribute-set
Introduce an object to aid in creation and management of `@attributes`
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb10
1 files changed, 2 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index b4d75d6556..268cec6160 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -230,7 +230,7 @@ module ActiveRecord
# For queries selecting a subset of columns, return false for unselected columns.
# We check defined?(@attributes) not to issue warnings if called on objects that
# have been allocated but not yet initialized.
- if defined?(@attributes) && @attributes.any? && self.class.column_names.include?(name)
+ if defined?(@attributes) && self.class.column_names.include?(name)
return has_attribute?(name)
end
@@ -247,7 +247,7 @@ module ActiveRecord
# person.has_attribute?('age') # => true
# person.has_attribute?(:nothing) # => false
def has_attribute?(attr_name)
- @attributes.has_key?(attr_name.to_s)
+ @attributes.include?(attr_name.to_s)
end
# Returns an array of names for the attributes available on this object.
@@ -367,12 +367,6 @@ module ActiveRecord
protected
- def clone_attributes # :nodoc:
- @attributes.each_with_object({}) do |(name, attr), h|
- h[name] = attr.dup
- end
- end
-
def clone_attribute_value(reader_method, attribute_name) # :nodoc:
value = send(reader_method, attribute_name)
value.duplicable? ? value.clone : value