Module: UseContext::ContextMethods
- Included in:
- Kernel, Kernel, UseContext
- Defined in:
- lib/use_context.rb
Instance Method Summary collapse
- #provide_context(name, context_hash) ⇒ Object
- #use_context(name) {|UseContext.context[name]&.context || EmptyContext.instance| ... } ⇒ Object
Instance Method Details
#provide_context(name, context_hash) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/use_context.rb', line 60 def provide_context(name, context_hash) context = UseContext.context[name] ||= ContextStack.new context.push(context_hash) yield ensure context.pop if context end |
#use_context(name) {|UseContext.context[name]&.context || EmptyContext.instance| ... } ⇒ Object
68 69 70 |
# File 'lib/use_context.rb', line 68 def use_context(name) yield UseContext.context[name]&.context || EmptyContext.instance end |