Class: Ccp::Utils::Options::Proxy
- Inherits:
-
Object
- Object
- Ccp::Utils::Options::Proxy
- Includes:
- Enumerable
- Defined in:
- lib/ccp/utils/options.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(base, *keys) ⇒ Proxy
constructor
A new instance of Proxy.
- #options ⇒ Object
Constructor Details
#initialize(base, *keys) ⇒ Proxy
Returns a new instance of Proxy.
19 20 21 22 23 24 25 26 27 |
# File 'lib/ccp/utils/options.rb', line 19 def initialize(base, *keys) @base = base @keys = keys.map(&:to_sym) @keys.each do |key| @base.dsl_accessor key # instance_eval "def self.#{key}; :#{key}; end" end end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
17 18 19 |
# File 'lib/ccp/utils/options.rb', line 17 def keys @keys end |
Instance Method Details
#[](key) ⇒ Object
29 30 31 |
# File 'lib/ccp/utils/options.rb', line 29 def [](key) @base.__send__(key) end |
#each(&block) ⇒ Object
33 34 35 36 37 |
# File 'lib/ccp/utils/options.rb', line 33 def each(&block) keys.each do |key| yield(self[key]) end end |
#options ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ccp/utils/options.rb', line 39 def opts = {} keys.each do |key| val = self[key] opts[key] = val unless val.nil? end return opts end |