Class: ActiveDecorator::ViewContext
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- ActiveDecorator::ViewContext
- Defined in:
- lib/active_decorator/view_context.rb,
lib/active_decorator/view_context.rb,
lib/active_decorator/view_context.rb
Overview
Fallback implementation for Rails < 5.2
Defined Under Namespace
Modules: Filter
Class Method Summary collapse
- .current ⇒ Object
- .pop ⇒ Object
- .push(view_context) ⇒ Object
- .run_with(view_context) ⇒ Object
- .view_context_stack ⇒ Object
Instance Method Summary collapse
Class Method Details
.current ⇒ Object
36 37 38 |
# File 'lib/active_decorator/view_context.rb', line 36 def current view_context_stack.last end |
.pop ⇒ Object
44 45 46 |
# File 'lib/active_decorator/view_context.rb', line 44 def pop view_context_stack.pop end |
.push(view_context) ⇒ Object
40 41 42 |
# File 'lib/active_decorator/view_context.rb', line 40 def push(view_context) view_context_stack.push view_context end |
.run_with(view_context) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/active_decorator/view_context.rb', line 48 def run_with(view_context) push view_context yield ensure pop end |
.view_context_stack ⇒ Object
27 28 29 |
# File 'lib/active_decorator/view_context.rb', line 27 def view_context_stack Thread.current[:active_decorator_view_contexts] ||= [] end |
Instance Method Details
#view_context_stack ⇒ Object
14 15 16 |
# File 'lib/active_decorator/view_context.rb', line 14 def view_context_stack attributes[:view_context_stack] ||= [] end |