Sha256: 3721d3bdd4ce015ae85df723f2568bb53d73e886a9665f0d84c3ca05e33e8ce4
Contents?: true
Size: 1.17 KB
Versions: 18
Compression:
Stored size: 1.17 KB
Contents
module Scorpion # Chains hunting calls to one or more managed scorpions. class ChainHunter include Scorpion # ============================================================================ # @!group Attributes # # @!attribute # @return [Array<Scorpion>] scorpions to chain hunting calls to. attr_reader :scorpions # # @!endgroup Attributes def initialize( *scorpions ) @scorpions = scorpions end # Prepare the scorpion for hunting. # @see DependencyMap#chart def prepare( &block ) if top = scorpions.first top.prepare &block end end # @see Scorpion#replicate def replicate self.class.new scorpions end # @see Scorpion#hunt def execute( hunt ) # Try explicitly defined dependencies first scorpions.each do |hunter| begin return hunter.execute( hunt, true ) rescue UnsuccessfulHunt end end # Then allow implicit scorpions.each do |hunter| begin return hunter.execute( hunt ) rescue UnsuccessfulHunt end end unsuccessful_hunt hunt.contract, hunt.traits end end end
Version data entries
18 entries across 18 versions & 1 rubygems