Class: Crystal::Conveyor
Instance Method Summary collapse
- #build! ⇒ Object
- #call(workspace_content = {}, &block) ⇒ Object
- #definitions ⇒ Object
- #inspect ⇒ Object
- #use(processor_class, *initialization_arguments) ⇒ Object
Instance Method Details
#build! ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/crystal/conveyor/conveyor.rb', line 13 def build! @chain = lambda{} definitions.reverse.collect do |klass, args| klass.must_be.a Class @chain = klass.new @chain, *args end end |
#call(workspace_content = {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/crystal/conveyor/conveyor.rb', line 21 def call workspace_content = {}, &block build! unless @chain crystal.activate :cycle, {} do self.workspace = Workspace.new workspace.merge! workspace_content if block block.call{@chain.call} else @chain.call end workspace end end |
#definitions ⇒ Object
5 6 7 |
# File 'lib/crystal/conveyor/conveyor.rb', line 5 def definitions @definitions ||= [] end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/crystal/conveyor/conveyor.rb', line 38 def inspect definitions.inspect end |
#use(processor_class, *initialization_arguments) ⇒ Object
9 10 11 |
# File 'lib/crystal/conveyor/conveyor.rb', line 9 def use processor_class, *initialization_arguments definitions << [processor_class, initialization_arguments] end |