Class: Pharrell::Config
- Inherits:
-
Object
- Object
- Pharrell::Config
- Defined in:
- lib/pharrell/config.rb
Defined Under Namespace
Classes: Binder
Instance Method Summary collapse
- #extend(definition) ⇒ Object
-
#initialize(definition) ⇒ Config
constructor
A new instance of Config.
- #instance_for(klass) ⇒ Object
- #rebuild! ⇒ Object
Constructor Details
#initialize(definition) ⇒ Config
Returns a new instance of Config.
3 4 5 |
# File 'lib/pharrell/config.rb', line 3 def initialize(definition) @definition = definition end |
Instance Method Details
#extend(definition) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/pharrell/config.rb', line 23 def extend(definition) agg_definition = proc { |binder| @definition.call(binder) definition.call(binder) } Config.new(agg_definition) end |
#instance_for(klass) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/pharrell/config.rb', line 7 def instance_for(klass) binding = @bindings[klass] if binding binding.call(self) else raise BindingNotFoundError.new(klass) end end |
#rebuild! ⇒ Object
17 18 19 20 21 |
# File 'lib/pharrell/config.rb', line 17 def rebuild! @bindings = Binder.new.tap { |b| @definition.call(b) }.bindings end |