Skip to content
Browse files

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

This reverts commit 90df0d4, reversing
changes made to 5e6fc81.

Reason: build breakage
  • Loading branch information...
1 parent 6e5b98e commit 9bae926ff254ae202308af949109e110aec7c3b9 @jonleighton jonleighton committed
Showing with 14 additions and 1 deletion.
  1. +14 −1 activesupport/lib/active_support/core_ext/class/attribute.rb
View
15 activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -81,13 +81,21 @@ 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} : singleton_class.#{name}
+ defined?(@#{name}) ? @#{name} : self.class.#{name}
end
def #{name}?
@@ -99,4 +107,9 @@ def #{name}?
attr_writer name if instance_writer
end
end
+
+ private
+ def singleton_class?
+ !name || '' == name
+ end
end

0 comments on commit 9bae926

Please sign in to comment.
Something went wrong with that request. Please try again.