提交 90df0d4f 编写于 作者: A Aaron Patterson

Merge pull request #4220 from bensie/singleton-class-master

Further simplify singleton_class checking in class_attribute
......@@ -81,21 +81,13 @@ def self.#{name}=(val)
define_method(:#{name}) { val }
end
if singleton_class?
class_eval do
remove_possible_method(:#{name})
def #{name}
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
end
end
end
val
end
if instance_reader
remove_possible_method :#{name}
def #{name}
defined?(@#{name}) ? @#{name} : self.class.#{name}
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
end
def #{name}?
......@@ -107,9 +99,4 @@ def #{name}?
attr_writer name if instance_writer
end
end
private
def singleton_class?
!name || '' == name
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册