Sha256: 2c5b4c6e01df5ebcdb0c9f8c4baa3827bdb282dc0d2e034f6fcdd7a6d1dd1b75

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

module CacheSwitchingMacros
  def enable_cache(trigger = :all)
    before(trigger) do
      @__perform_caching_before ||= []
      @__perform_caching_before.push Rails.application.config.action_controller.perform_caching
      Rails.application.config.action_controller.perform_caching = true
    end

    after(trigger) do
      @__perform_caching_before ||= []
      previous_setting = @__perform_caching_before.pop || false
      Rails.application.config.action_controller.perform_caching = previous_setting
    end
  end

  def disable_cache(trigger = :all)
    before(trigger) do
      @__perform_caching_before ||= []
      @__perform_caching_before.push Rails.application.config.action_controller.perform_caching
      Rails.application.config.action_controller.perform_caching = false
    end

    after(trigger) do
      @__perform_caching_before ||= []
      previous_setting = @__perform_caching_before.pop || false
      Rails.application.config.action_controller.perform_caching = previous_setting
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
infopark_component_cache-5.0.2 spec/support/cache_switching_macros.rb
infopark_component_cache-5.0.1 spec/support/cache_switching_macros.rb
infopark_component_cache-4.2.0 spec/support/cache_switching_macros.rb
infopark_component_cache-4.1.0 spec/support/cache_switching_macros.rb
infopark_component_cache-4.0.1 spec/support/cache_switching_macros.rb
infopark_component_cache-4.0.0 spec/support/cache_switching_macros.rb