diff options
author | Michael S. Klishin <michael@novemberain.com> | 2008-12-28 23:47:29 +0300 |
---|---|---|
committer | Michael S. Klishin <michael@novemberain.com> | 2008-12-28 23:47:29 +0300 |
commit | 2b8750eba439c4b829b2e8172a1edc0dfa9c532b (patch) | |
tree | 1ea12e7fe5ad299119d801c7e7f527f6b7780bc3 /activesupport/lib/active_support/core_ext/class/delegating_attributes.rb | |
parent | e523b43e202d343912f67b8c8737d9e2e956b31f (diff) | |
parent | 0efec64520d5153e5a961f9a759883656b83bb53 (diff) | |
download | rails-2b8750eba439c4b829b2e8172a1edc0dfa9c532b.tar.gz rails-2b8750eba439c4b829b2e8172a1edc0dfa9c532b.tar.bz2 rails-2b8750eba439c4b829b2e8172a1edc0dfa9c532b.zip |
Sync with rails/rails/master, merge two metaprogramming annotation efforts
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.rb | 33 |
1 files changed, 17 insertions, 16 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 3b093a9a65..d893818695 100644 --- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb @@ -9,22 +9,23 @@ class Class class_name_to_stop_searching_on = self.superclass.name.blank? ? "Object" : self.superclass.name names.each do |name| 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 + def self.#{name} # def self.only_reader + if defined?(@#{name}) # if defined?(@only_reader) + @#{name} # @only_reader + elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object && + superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader) + superclass.#{name} # superclass.only_reader + end # end + end # end + def #{name} # def only_reader + self.class.#{name} # self.class.only_reader + end # end + def self.#{name}? # def self.only_reader? + !!#{name} # !!only_reader + end # end + def #{name}? # def only_reader? + !!#{name} # !!only_reader + end # end EOS end end |