提交 a86e5949 编写于 作者: M Michael Koziarski

Stop respond_to? from throwing when instances are created 'irregularly' i.e....

Stop respond_to? from throwing when instances are created 'irregularly' i.e. yaml loads.  [zenspider] Closes #4587


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4172 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 58c435a3
*SVN*
* Allow AR::Base#respond_to? to behave when @attributes is nil [zenspider]
* Support eager includes when going through a polymorphic has_many association. [Rick]
* Added support for eagerly including polymorphic has_one associations. (closes #4525) [Rick]
......
......@@ -1587,7 +1587,9 @@ def hash
# A Person object with a name attribute can ask person.respond_to?("name"), person.respond_to?("name="), and
# person.respond_to?("name?") which will all return true.
def respond_to?(method, include_priv = false)
if attr_name = self.class.column_methods_hash[method.to_sym]
if @attributes.nil?
return super
elsif attr_name = self.class.column_methods_hash[method.to_sym]
return true if @attributes.include?(attr_name) || attr_name == self.class.primary_key
return false if self.class.read_methods.include?(attr_name)
elsif @attributes.include?(method_name = method.to_s)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册