Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Further simplify singleton_class checking in class_attribute
  • Loading branch information...
commit 90df0d4f687596943bda108ab0b98dd99cacd46b 2 parents 5e6fc81 + cdf7a60
Aaron Patterson tenderlove authored
Showing with 1 addition and 14 deletions.
  1. +1 −14 activesupport/lib/active_support/core_ext/class/attribute.rb
15 activesupport/lib/active_support/core_ext/class/attribute.rb
View
@@ -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

4 comments on commit 90df0d4

Jon Leighton
Collaborator

I've reverted in 9bae926. @bensie please feel free to submit a new PR when you've had a chance to investigate the breakage. thanks.

Aaron Patterson
Owner

@jonleighton sorry bro, I should have run the tests before merging this!

Jon Leighton
Collaborator

@tenderlove no worries sista, looks like a corner case that isn't covered by activesupport tests anyway, so needs some sleuthing!

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