Sha256: 8e5cc1030e243f5aaeaa8a6c8c342a08ca7f39e0a364938ea8831db73db6b023

Contents?: true

Size: 405 Bytes

Versions: 6

Compression:

Stored size: 405 Bytes

Contents

module Dependor
  class Instantiator
    def initialize(injector)
      @injector = injector
    end

    def instantiate(klass)
      params = klass.instance_method(:initialize).parameters
      dependency_names = params.select{|type, name| type == :req}.map{|type, name| name}
      dependencies = dependency_names.map{|name| @injector.get(name)}
      return klass.new(*dependencies)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dependor-0.0.6 lib/dependor/instantiator.rb
dependor-0.0.5 lib/dependor/instantiator.rb
dependor-0.0.4 lib/dependor/instantiator.rb
dependor-0.0.3 lib/dependor/instantiator.rb
dependor-0.0.2 lib/dependor/instantiator.rb
dependor-0.0.1 lib/dependor/instantiator.rb