Class: Class

Inherits:
Object
  • Object
show all
Defined in:
lib/action_web_service/support/class_inheritable_options.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#class_inheritable_option(sym, default_value = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/action_web_service/support/class_inheritable_options.rb', line 2

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