From 9c83e8401d802864dde38ddffb690a4245d01716 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 11 Jul 2014 07:50:16 -0600 Subject: AttributeSet#include? -> AttributeSet#key? https://github.com/rails/rails/pull/15868/files#r14135210 --- activerecord/lib/active_record/attribute_methods.rb | 4 ++-- activerecord/lib/active_record/attribute_set.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index e3ac891520..d728fb5ddf 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -251,7 +251,7 @@ module ActiveRecord # person.has_attribute?('age') # => true # person.has_attribute?(:nothing) # => false def has_attribute?(attr_name) - @attributes.include?(attr_name.to_s) + @attributes.key?(attr_name.to_s) end # Returns an array of names for the attributes available on this object. @@ -386,7 +386,7 @@ module ActiveRecord def attribute_method?(attr_name) # :nodoc: # We check defined? because Syck calls respond_to? before actually calling initialize. - defined?(@attributes) && @attributes.include?(attr_name) + defined?(@attributes) && @attributes.key?(attr_name) end private diff --git a/activerecord/lib/active_record/attribute_set.rb b/activerecord/lib/active_record/attribute_set.rb index 64df6f6358..98ac63c7e1 100644 --- a/activerecord/lib/active_record/attribute_set.rb +++ b/activerecord/lib/active_record/attribute_set.rb @@ -21,8 +21,8 @@ module ActiveRecord end alias_method :to_h, :to_hash - def include?(name) - attributes.include?(name) && self[name].initialized? + def key?(name) + attributes.key?(name) && self[name].initialized? end def fetch_value(name, &block) @@ -53,7 +53,7 @@ module ActiveRecord end def reset(key) - if include?(key) + if key?(key) write_from_database(key, nil) end end -- cgit v1.2.3