aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-08-14 12:34:38 -0300
committerEmilio Tagua <miloops@gmail.com>2009-08-14 12:34:38 -0300
commit48c1e6d584409d774b184e0f4d2ef28e5b0e9c90 (patch)
treea2becf0cce37a47579e848780b02f420d335ccd9 /activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
parent9ac01fad193b27e517ea772e0d1e13e06f4ddf34 (diff)
parentc6bc8e662614be711f45a8d4b231d5f993b024a7 (diff)
downloadrails-48c1e6d584409d774b184e0f4d2ef28e5b0e9c90.tar.gz
rails-48c1e6d584409d774b184e0f4d2ef28e5b0e9c90.tar.bz2
rails-48c1e6d584409d774b184e0f4d2ef28e5b0e9c90.zip
Merge commit 'rails/master'
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.rb7
1 files changed, 4 insertions, 3 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 fd029544c3..6c67df7f50 100644
--- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
+++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
@@ -26,13 +26,14 @@ class Class
end
end
- def superclass_delegating_writer(*names)
+ def superclass_delegating_writer(*names, &block)
names.each do |name|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def self.#{name}=(value) # def self.property=(value)
@#{name} = value # @property = value
end # end
EOS
+ self.send("#{name}=", yield) if block_given?
end
end
@@ -42,8 +43,8 @@ class Class
# delegate to their superclass unless they have been given a
# specific value. This stops the strange situation where values
# set after class definition don't get applied to subclasses.
- def superclass_delegating_accessor(*names)
+ def superclass_delegating_accessor(*names, &block)
superclass_delegating_reader(*names)
- superclass_delegating_writer(*names)
+ superclass_delegating_writer(*names, &block)
end
end