class Detroit::Toolchain::Worker
Service class wraps a Tool
instance when it is made part of an assembly.
TODO: Perhpas a better name would be ‘Link`, as in “chain link”?
Attributes
active[R]
key[R]
priority[R]
tool[R]
track[R]
Public Class Methods
new(key, tool_class, options)
click to toggle source
Create new wrapper.
# File lib/detroit/toolchain/worker.rb, line 41 def initialize(key, tool_class, options) @key = key ## set defaults @track = nil @priority = 0 @active = true self.active = options.delete('active') if !options['active'].nil? self.track = options.delete('track') if options.key?('track') self.priority = options.delete('priority') if options.key?('priority') @tool = tool_class.new(options) end
Public Instance Methods
active=(boolean)
click to toggle source
# File lib/detroit/toolchain/worker.rb, line 35 def active=(boolean) @active = !!boolean end
inspect()
click to toggle source
# File lib/detroit/toolchain/worker.rb, line 76 def inspect "<#{self.class}:#{object_id} @key='#{key}'>" end
invoke(station, stop=nil)
click to toggle source
Run the service assembly station procedure.
# File lib/detroit/toolchain/worker.rb, line 71 def invoke(station, stop=nil) @tool.assemble(station.to_sym, :destination=>stop.to_sym) end
priority=(integer)
click to toggle source
Set the priority. Priority determines the order which services on the same stop are run.
# File lib/detroit/toolchain/worker.rb, line 24 def priority=(integer) @priority = integer.to_i end
stop?(station, stop=nil)
click to toggle source
Does the tool handle the given assembly station?
If ‘true` is returned than the station is handled by a method in the tool with the same name.
If a symbol is returned then the station is handled, but via the method named by the returned symbol.
@return [Boolean,Symbol]
# File lib/detroit/toolchain/worker.rb, line 65 def stop?(station, stop=nil) @tool.assemble?(station.to_sym, :destination=>stop.to_sym) end
track=(list)
click to toggle source
Set the tracks a service will be available on.
# File lib/detroit/toolchain/worker.rb, line 30 def track=(list) @track = list.to_list end