Permalink
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...
1 parent 69f62ec commit 8601f733af3311e3b0ebb1f517432593c9b0fedd @josevalim josevalim committed Jul 30, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -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

0 comments on commit 8601f73

Please sign in to comment.