Sha256: 4c8f8bf337008267496b9c21e66f641536e24800cdc9402777f16aa859ba7ba7
Contents?: true
Size: 996 Bytes
Versions: 6
Compression:
Stored size: 996 Bytes
Contents
require 'scorpion/dependency' module Scorpion class Dependency # {Dependency} that delegates to another object that implements # #call( scorpion, *args, &block ). class BuilderDependency < Scorpion::Dependency # ============================================================================ # @!group Attributes # # @!attribute # @return [#call(scorpion,*args,&block)] the builder to use to fetch instances of the dependency. attr_reader :builder # # @!endgroup Attributes def initialize( contract, traits = nil, builder = nil, &block ) @builder = block_given? ? block : builder super contract, traits end # @see Scorpion::Dependency#fetch def fetch( hunt ) if hunt.dependencies.any? builder.call( hunt, *hunt.arguments, **hunt.dependencies, &hunt.block ) else builder.call( hunt, *hunt.arguments, &hunt.block ) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems