From e7a29380292902eae4799b2658507b3cfffb9cec Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 18 Feb 2005 10:35:25 +0000 Subject: Added Action Service to the repository git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@658 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../support/class_inheritable_options.rb | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 actionservice/lib/action_service/support/class_inheritable_options.rb (limited to 'actionservice/lib/action_service/support/class_inheritable_options.rb') diff --git a/actionservice/lib/action_service/support/class_inheritable_options.rb b/actionservice/lib/action_service/support/class_inheritable_options.rb new file mode 100644 index 0000000000..4d1c2ed471 --- /dev/null +++ b/actionservice/lib/action_service/support/class_inheritable_options.rb @@ -0,0 +1,26 @@ +class Class # :nodoc: + def class_inheritable_option(sym, default_value=nil) + write_inheritable_attribute sym, default_value + class_eval <<-EOS + def self.#{sym}(value=nil) + if !value.nil? + write_inheritable_attribute(:#{sym}, value) + else + read_inheritable_attribute(:#{sym}) + end + end + + def self.#{sym}=(value) + write_inheritable_attribute(:#{sym}, value) + end + + def #{sym} + self.class.#{sym} + end + + def #{sym}=(value) + self.class.#{sym} = value + end + EOS + end +end -- cgit v1.2.3