Class: Makery::Builder
- Inherits:
-
Struct
- Object
- Struct
- Makery::Builder
- Defined in:
- lib/makery.rb
Overview
makes stuff
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instantiation_method ⇒ Object
Returns the value of attribute instantiation_method.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs
51 52 53 |
# File 'lib/makery.rb', line 51 def attrs @attrs end |
#id ⇒ Object
Returns the value of attribute id
51 52 53 |
# File 'lib/makery.rb', line 51 def id @id end |
#instantiation_method ⇒ Object
Returns the value of attribute instantiation_method
51 52 53 |
# File 'lib/makery.rb', line 51 def instantiation_method @instantiation_method end |
#klass ⇒ Object
Returns the value of attribute klass
51 52 53 |
# File 'lib/makery.rb', line 51 def klass @klass end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
52 53 54 |
# File 'lib/makery.rb', line 52 def obj @obj end |
Class Method Details
.call(*args) ⇒ Object
53 54 55 |
# File 'lib/makery.rb', line 53 def self.call(*args) new(*args).call end |
Instance Method Details
#[](attr) ⇒ Object
68 69 70 71 |
# File 'lib/makery.rb', line 68 def [](attr) a = attrs[attr] a.respond_to?(:call) ? a.call(self) : a end |
#call ⇒ Object
57 58 59 60 61 |
# File 'lib/makery.rb', line 57 def call @obj = klass.send(instantiation_method) transform @obj end |
#transform ⇒ Object
63 64 65 66 |
# File 'lib/makery.rb', line 63 def transform attrs.each { |k, v| attrs[k] = (v.respond_to?(:call) ? v.call(self) : v) } attrs.each { |k, v| @obj.send("#{k}=", v) } end |