aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/lib/action_service/support/class_inheritable_options.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionwebservice/lib/action_service/support/class_inheritable_options.rb')
-rw-r--r--actionwebservice/lib/action_service/support/class_inheritable_options.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/actionwebservice/lib/action_service/support/class_inheritable_options.rb b/actionwebservice/lib/action_service/support/class_inheritable_options.rb
new file mode 100644
index 0000000000..4d1c2ed471
--- /dev/null
+++ b/actionwebservice/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