Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "DRY class_attribute code"

class_attribute is a building block and using define_method
can be much slower for such basic method definitions.

This reverts commit d59208d.
  • Loading branch information...
commit 8601f733af3311e3b0ebb1f517432593c9b0fedd 1 parent 69f62ec
José Valim josevalim authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 activesupport/lib/active_support/core_ext/class/attribute.rb
9 activesupport/lib/active_support/core_ext/class/attribute.rb
View
@@ -79,12 +79,14 @@ def self.#{name}?() !!#{name} end
def self.#{name}=(val)
singleton_class.class_eval do
- redefine_method(:#{name}) { val }
+ remove_possible_method(:#{name})
+ define_method(:#{name}) { val }
end
if singleton_class?
class_eval do
- redefine_method(:#{name}) do
+ remove_possible_method(:#{name})
+ def #{name}
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
end
end
@@ -93,7 +95,8 @@ def self.#{name}=(val)
end
if instance_reader
- redefine_method(:#{name}) do
+ remove_possible_method :#{name}
+ def #{name}
defined?(@#{name}) ? @#{name} : self.class.#{name}
end
Please sign in to comment.
Something went wrong with that request. Please try again.