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.
29 30 31 |
# File 'lib/pharrell/config.rb', line 29 def initialize @bindings = {} end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
27 28 29 |
# File 'lib/pharrell/config.rb', line 27 def bindings @bindings end |
Instance Method Details
#bind(klass, arg = nil, &blk) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pharrell/config.rb', line 33 def bind(klass, arg = nil, &blk) if blk = arg.kind_of?(Hash) ? arg : {} @bindings[klass] = blk else obj_block = if arg.kind_of?(Class) Proc.new { arg.new } else Proc.new { arg } end @bindings[klass] = obj_block end end |