Sha256: ad8c8bceb58971d7aed05a0e190353713b91bf20eb0047975b7a21eaa26fbd8a

Contents?: true

Size: 774 Bytes

Versions: 26

Compression:

Stored size: 774 Bytes

Contents

require 'scorpion/dependency'

module Scorpion
  class Dependency
    # {Dependency} for a {Class} contract
    class ClassDependency < Scorpion::Dependency

      def fetch( hunt )
        resolved = resolve_dependencies( hunt )
        hunt.scorpion.spawn hunt, hunt.contract, *hunt.arguments, **resolved, &hunt.block
      end

      private

        def resolve_dependencies( hunt )
          dependencies = hunt.dependencies
          return dependencies unless hunt.contract.respond_to? :initializer_injections

          hunt.contract.initializer_injections.each_with_object(dependencies.dup) do |attr,deps|
            next if attr.lazy?

            deps[attr.name] ||= hunt.fetch_by_traits( attr.contract, attr.traits )
          end
        end

    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
scorpion-ioc-0.6.2 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.6.1 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.6.0 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.23 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.22 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.21 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.20 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.19 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.18 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.17 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.16 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.15 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.14 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.13 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.12 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.11 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.10 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.9 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.8 lib/scorpion/dependency/class_dependency.rb
scorpion-ioc-0.5.7 lib/scorpion/dependency/class_dependency.rb