Sha256: 5833ef0c9b0173f10df1f0e053280e5252d1bd8250be8cb10bf7ceddce71f50c
Contents?: true
Size: 1.19 KB
Versions: 8
Compression:
Stored size: 1.19 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.map( &:replicate ) 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
8 entries across 8 versions & 1 rubygems