Sha256: a4a3d69a2fd1f5a42048a9760b978eee0cb23d5eb267c5870c77ded33553ac79
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true # A module that carries the controllers' view_context to decorators. module ActiveDecorator module ViewContext class << self def current view_context_stack.last end def push(view_context) view_context_stack.push view_context end def pop view_context_stack.pop end def view_context_stack Thread.current[:active_decorator_view_contexts] ||= [] end def run_with(view_context) push view_context yield ensure pop end end module Filter extend ActiveSupport::Concern included do if Rails::VERSION::MAJOR >= 4 around_action do |controller, blk| ActiveDecorator::ViewContext.run_with(controller.view_context) do blk.call end end else around_filter do |controller, blk| ActiveDecorator::ViewContext.run_with(controller.view_context) do blk.call end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_decorator-1.0.0 | lib/active_decorator/view_context.rb |