Class: Invokr::DependencyInjection::HashResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/invokr/dependency_injection.rb

Instance Method Summary collapse

Constructor Details

#initialize(hsh) ⇒ HashResolver

Returns a new instance of HashResolver.



75
76
77
# File 'lib/invokr/dependency_injection.rb', line 75

def initialize hsh
  @hsh = hsh
end

Instance Method Details

#could_resolve?(val) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/invokr/dependency_injection.rb', line 90

def could_resolve? val
  @hsh.has_key? val
end

#inject(klass) ⇒ Object



79
80
81
82
83
84
# File 'lib/invokr/dependency_injection.rb', line 79

def inject klass
  DependencyInjection.inject(
    :klass => klass,
    :using => self,
  )
end

#resolve(val, &block) ⇒ Object



86
87
88
# File 'lib/invokr/dependency_injection.rb', line 86

def resolve val, &block
  @hsh.fetch val, &block
end