Sha256: 8d824483bd68a21589a26f0ff42a7880aea2fc9e824416580215499a9ea61187
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 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 # 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 end end
Version data entries
9 entries across 9 versions & 1 rubygems