Class: Pharrell::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/pharrell/config.rb

Defined Under Namespace

Classes: Binder

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ Config

Returns a new instance of Config.



5
6
7
8
# File 'lib/pharrell/config.rb', line 5

def initialize(definition)
  @definition = definition
  rebuild!
end

Instance Method Details

#extend(definition) ⇒ Object



20
21
22
# File 'lib/pharrell/config.rb', line 20

def extend(definition)
  Config.new(@definition + definition)
end

#instance_for(klass) ⇒ Object



10
11
12
# File 'lib/pharrell/config.rb', line 10

def instance_for(klass)
  @bindings[klass].call
end

#rebuild!Object



14
15
16
17
18
# File 'lib/pharrell/config.rb', line 14

def rebuild!
  @bindings =  Binder.new.tap { |b|
    @definition.call(b)
  }.bindings
end