Module: Granite::ContextProxy::ClassMethods
- Defined in:
- lib/granite/context_proxy.rb
Overview
:nodoc:
Constant Summary collapse
- PROXY_CONTEXT_KEY =
:granite_proxy_context
Instance Method Summary collapse
- #as(performer) ⇒ Object
- #proxy_context ⇒ Object
- #with(data) ⇒ Object
- #with_context(context) ⇒ Object
Instance Method Details
#as(performer) ⇒ Object
17 18 19 |
# File 'lib/granite/context_proxy.rb', line 17 def as(performer) with(performer: performer) end |
#proxy_context ⇒ Object
29 30 31 |
# File 'lib/granite/context_proxy.rb', line 29 def proxy_context Thread.current[PROXY_CONTEXT_KEY] end |
#with(data) ⇒ Object
13 14 15 |
# File 'lib/granite/context_proxy.rb', line 13 def with(data) Proxy.new(self, Data.wrap(data)) end |
#with_context(context) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/granite/context_proxy.rb', line 21 def with_context(context) old_context = proxy_context Thread.current[PROXY_CONTEXT_KEY] = context yield ensure Thread.current[PROXY_CONTEXT_KEY] = old_context end |