Class: Pharrell::Config::Binder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBinder

Returns a new instance of Binder.



37
38
39
# File 'lib/pharrell/config.rb', line 37

def initialize
  @bindings = {}
end

Instance Attribute Details

#bindingsObject (readonly)

Returns the value of attribute bindings.



35
36
37
# File 'lib/pharrell/config.rb', line 35

def bindings
  @bindings
end

Instance Method Details

#bind(klass, arg = nil, &blk) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pharrell/config.rb', line 41

def bind(klass, arg = nil, &blk)
  if blk
    @bindings[klass] = blk
  else
    obj_block = if arg.kind_of?(Class)
      Proc.new { |config| build_instance(arg, config)}
    else
      Proc.new { arg }
    end

    @bindings[klass] = obj_block
  end
end