Sha256: e89cc00c5b2ddcaece4ec044aef996faeb9316781c14465ff1e729a196f9ccec

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

require 'scorpion/dependency'

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

      def fetch( hunt )
        hunt.scorpion.spawn hunt, hunt.contract, *resolve_arguments( hunt ), &hunt.block
      end

      private

        def resolve_arguments( hunt )
          arguments = hunt.arguments
          return arguments unless arguments.blank? && hunt.contract < Scorpion::Object

          hunt.contract.initializer_injections.each_with_object([]) do |attr,args|
            args << hunt.fetch_by_traits( attr.contract, attr.traits )
          end

        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scorpion-ioc-0.4.0 lib/scorpion/dependency/class_dependency.rb