Class: Pharrell::Config::Binder
- Inherits:
-
Object
- Object
- Pharrell::Config::Binder
- Defined in:
- lib/pharrell/config.rb
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
Instance Method Summary collapse
- #bind(klass, arg = nil, &blk) ⇒ Object
-
#initialize ⇒ Binder
constructor
A new instance of Binder.
Constructor Details
#initialize ⇒ Binder
Returns a new instance of Binder.
37 38 39 |
# File 'lib/pharrell/config.rb', line 37 def initialize @bindings = {} end |
Instance Attribute Details
#bindings ⇒ Object (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 |