Sha256: 95cd88298d649466891c9d50382ad3702c68d4ce5a12f23875d5a2ac8afef114

Contents?: true

Size: 547 Bytes

Versions: 22

Compression:

Stored size: 547 Bytes

Contents

decorate JbuilderTemplate, with: :workarea do
  def _cache_fragment_for(*)
    return yield if workarea_admin?

    super
  end

  def _cache_key(*)
    super.tap do |result|
      result << workarea_cache_varies if workarea_cache_varies.present?
    end
  end

  private

  def workarea_admin?
    @context&.controller&.current_user&.admin?
  rescue ::RuntimeError
    false
  end

  def workarea_cache_varies
    workarea_request_env['workarea.cache_varies']
  end

  def workarea_request_env
    @context.controller.request.env || {}
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
workarea-core-3.5.27 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.26 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.45 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.25 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.23 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.44 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.22 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.43 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.21 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.42 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.20 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.41 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.19 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.40 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.18 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.39 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.17 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.38 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.5.16 lib/workarea/ext/jbuilder/jbuilder_cache.rb
workarea-core-3.4.37 lib/workarea/ext/jbuilder/jbuilder_cache.rb