Class: Batsir::Config::ConfigBlock
- Inherits:
-
Object
- Object
- Batsir::Config::ConfigBlock
- Defined in:
- lib/batsir/config.rb
Overview
class << self
Instance Method Summary collapse
-
#initialize(klass, &block) ⇒ ConfigBlock
constructor
Evaluates the provided block, where any call to a method causes #[]= to be called on klass with the method name as the key and the arguments as the value.
-
#method_missing(method, *args) ⇒ Object
Assign args as the value of the entry keyed by method.
Constructor Details
#initialize(klass, &block) ⇒ ConfigBlock
Evaluates the provided block, where any call to a method causes #[]= to be called on klass with the method name as the key and the arguments as the value.
Parameters
- klass<Object~[]=>
-
The object on which to assign values.
- &block
-
The block which specifies the config values to set.
Returns
nil
:api: private
204 205 206 207 |
# File 'lib/batsir/config.rb', line 204 def initialize(klass, &block) @klass = klass instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Assign args as the value of the entry keyed by method.
:api: private
212 213 214 |
# File 'lib/batsir/config.rb', line 212 def method_missing(method, *args) @klass[method] = args.first end |