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.



71
72
73
# File 'lib/invokr/dependency_injection.rb', line 71

def initialize hsh
  @hsh = hsh
end

Instance Method Details

#could_resolve?(val) ⇒ Boolean

Returns:

  • (Boolean)


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

def could_resolve? val
  @hsh.has_key? val
end

#inject(klass) ⇒ Object



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

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

#resolve(val, &block) ⇒ Object



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

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