Class: ActionController::Caching::Actions::ActionCacheFilter
- Inherits:
-
Object
- Object
- ActionController::Caching::Actions::ActionCacheFilter
- Defined in:
- lib/action_controller/caching/actions.rb
Overview
:nodoc:
Instance Method Summary collapse
- #around(controller) ⇒ Object
-
#initialize(options, &block) ⇒ ActionCacheFilter
constructor
A new instance of ActionCacheFilter.
Constructor Details
#initialize(options, &block) ⇒ ActionCacheFilter
Returns a new instance of ActionCacheFilter.
149 150 151 152 |
# File 'lib/action_controller/caching/actions.rb', line 149 def initialize(, &block) @cache_path, , @cache_layout = .values_at(:cache_path, :store_options, :layout) end |
Instance Method Details
#around(controller) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/action_controller/caching/actions.rb', line 154 def around(controller) cache_layout = @cache_layout.respond_to?(:call) ? @cache_layout.call(controller) : @cache_layout = if @cache_path.is_a?(Proc) controller.instance_exec(controller, &@cache_path) elsif @cache_path.respond_to?(:call) @cache_path.call(controller) else @cache_path end cache_path = ActionCachePath.new(controller, || {}) body = controller.read_fragment(cache_path.path, ) unless body controller.action_has_layout = false unless cache_layout yield controller.action_has_layout = true body = controller._save_fragment(cache_path.path, ) end body = controller.render_to_string(body: body, layout: true) unless cache_layout controller.response_body = body controller.content_type = Mime[cache_path.extension || :html] end |