aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/class/delegating_attributes.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/class/delegating_attributes.rb42
1 files changed, 21 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
index 368317df9b..3b093a9a65 100644
--- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
+++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
@@ -8,33 +8,33 @@ class Class
def superclass_delegating_reader(*names)
class_name_to_stop_searching_on = self.superclass.name.blank? ? "Object" : self.superclass.name
names.each do |name|
- class_eval <<-EOS
- def self.#{name}
- if defined?(@#{name})
- @#{name}
- elsif superclass < #{class_name_to_stop_searching_on} && superclass.respond_to?(:#{name})
- superclass.#{name}
- end
- end
- def #{name}
- self.class.#{name}
- end
- def self.#{name}?
- !!#{name}
- end
- def #{name}?
- !!#{name}
- end
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def self.#{name} # def self.property
+ if defined?(@#{name}) # if defined?(@property)
+ @#{name} # @property
+ elsif superclass < #{class_name_to_stop_searching_on} && superclass.respond_to?(:#{name}) # elseif superclass < Object && superclass.respond_to?(:property)
+ superclass.#{name} # superclass.property
+ end # end
+ end # end
+ def #{name} # def property
+ self.class.#{name} # self.class.property
+ end # end
+ def self.#{name}? # def self.property?
+ !!#{name} # !!property
+ end # end
+ def #{name}? # def property?
+ !!#{name} # !!property
+ end # end
EOS
end
end
def superclass_delegating_writer(*names)
names.each do |name|
- class_eval <<-EOS
- def self.#{name}=(value)
- @#{name} = value
- end
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def self.#{name}=(value) # def self.property=(value)
+ @#{name} = value # @property = value
+ end # end
EOS
end
end