Class: LH::DependencyInjection::ContextHash
- Defined in:
- lib/lh/dependency_injection/context.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize ⇒ ContextHash
constructor
A new instance of ContextHash.
- #merge!(other_context) ⇒ Object
- #specify(key, value = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ ContextHash
Returns a new instance of ContextHash.
5 6 7 |
# File 'lib/lh/dependency_injection/context.rb', line 5 def initialize @context = { } end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/lh/dependency_injection/context.rb', line 13 def [](key) if @context[key].respond_to? :call @context[key] = @context[key].call end @context[key] end |
#has_key?(key) ⇒ Boolean
20 21 22 |
# File 'lib/lh/dependency_injection/context.rb', line 20 def has_key?(key) @context.has_key?(key) end |
#merge!(other_context) ⇒ Object
9 10 11 |
# File 'lib/lh/dependency_injection/context.rb', line 9 def merge!(other_context) @context.merge!(other_context.context) end |
#specify(key, value = nil, &block) ⇒ Object
24 25 26 |
# File 'lib/lh/dependency_injection/context.rb', line 24 def specify(key, value=nil, &block) @context[key] = value || block end |