class Scorpion::ChainHunter
Chains hunting calls to one or more managed scorpions.
Attributes
scorpions[R]
@!attribute @return [Array<Scorpion>] scorpions to chain hunting calls to.
Public Class Methods
new( *scorpions )
click to toggle source
@!endgroup Attributes
# File lib/scorpion/chain_hunter.rb, line 19 def initialize( *scorpions ) @scorpions = scorpions end
Public Instance Methods
execute( hunt )
click to toggle source
@see Scorpion#hunt
# File lib/scorpion/chain_hunter.rb, line 37 def execute( hunt ) # Try explicitly defined dependencies first scorpions.each do |hunter| begin return hunter.execute( hunt, true ) rescue UnsuccessfulHunt # rubocop:disable Lint/HandleExceptions end end # Then allow implicit scorpions.each do |hunter| begin return hunter.execute( hunt ) rescue UnsuccessfulHunt # rubocop:disable Lint/HandleExceptions end end unsuccessful_hunt hunt.contract end
prepare( &block )
click to toggle source
Prepare the scorpion for hunting. @see DependencyMap#chart
# File lib/scorpion/chain_hunter.rb, line 25 def prepare( &block ) if top = scorpions.first top.prepare &block end end
replicate()
click to toggle source
@see Scorpion#replicate
# File lib/scorpion/chain_hunter.rb, line 32 def replicate self.class.new *scorpions.map( &:replicate ) end