Sha256: 1005c011e9ceaadb41e674776a4e247faca15536ef63660671fe19f283adb107
Contents?: true
Size: 1.12 KB
Versions: 8
Compression:
Stored size: 1.12 KB
Contents
module ActiveDecorator module ViewContext class << self def current Thread.current[:active_decorator_view_contexts].last end def push(view_context) Thread.current[:active_decorator_view_contexts] ||= [] Thread.current[:active_decorator_view_contexts] << view_context end def pop Thread.current[:active_decorator_view_contexts].pop if Thread.current[:active_decorator_view_contexts] end end module Filter extend ActiveSupport::Concern included do if Rails::VERSION::MAJOR >= 4 around_action do |controller, blk| begin ActiveDecorator::ViewContext.push controller.view_context blk.call ensure ActiveDecorator::ViewContext.pop end end else around_filter do |controller, blk| begin ActiveDecorator::ViewContext.push controller.view_context blk.call ensure ActiveDecorator::ViewContext.pop end end end end end end end
Version data entries
8 entries across 8 versions & 2 rubygems