Class: AssemblyLine::Constructor
- Inherits:
-
Object
- Object
- AssemblyLine::Constructor
- Extended by:
- Forwardable
- Defined in:
- lib/assembly_line/constructor.rb
Instance Attribute Summary collapse
-
#code_block ⇒ Object
readonly
Returns the value of attribute code_block.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #assemble(context, options) ⇒ Object
- #depends_on(*constructors) ⇒ Object
-
#initialize(name, code_block) ⇒ Constructor
constructor
A new instance of Constructor.
- #invoke(*methods) ⇒ Object
Constructor Details
#initialize(name, code_block) ⇒ Constructor
Returns a new instance of Constructor.
9 10 11 12 |
# File 'lib/assembly_line/constructor.rb', line 9 def initialize(name, code_block) @name = name @code_block = code_block end |
Instance Attribute Details
#code_block ⇒ Object (readonly)
Returns the value of attribute code_block.
7 8 9 |
# File 'lib/assembly_line/constructor.rb', line 7 def code_block @code_block end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/assembly_line/constructor.rb', line 7 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/assembly_line/constructor.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/assembly_line/constructor.rb', line 7 def @options end |
Instance Method Details
#assemble(context, options) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/assembly_line/constructor.rb', line 14 def assemble(context, ) @options = @context = context instance_eval(&code_block) self end |
#depends_on(*constructors) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/assembly_line/constructor.rb', line 29 def depends_on(*constructors) if [:depends_on] constructors = Array([:depends_on]) end constructors.each do |name| AssemblyLine.assemble(name, context) end end |
#invoke(*methods) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/assembly_line/constructor.rb', line 21 def invoke(*methods) if methods.any? invoke_in_setup *methods else invoke_in_setup name end end |