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