Permalink
Browse files

Further simplify singleton_class checking in class_attribute

  • Loading branch information...
1 parent 40cab62 commit 520918aad9b84eee807eb42fcb32f57c152d50e0 @bensie bensie committed with tenderlove Dec 28, 2011
Showing with 1 addition and 14 deletions.
  1. +1 −14 activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -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

0 comments on commit 520918a

Please sign in to comment.