Class: Pundit::CacheStore::LegacyStore Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pundit/cache_store/legacy_store.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A cache store that uses only the record as a cache key, and ignores the user.

The original cache mechanism used by Pundit.

Since:

  • v2.3.2

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ LegacyStore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LegacyStore.

Since:

  • v2.3.2



13
14
15
# File 'lib/pundit/cache_store/legacy_store.rb', line 13

def initialize(hash = {})
  @store = hash
end

Instance Method Details

#fetch(user:, record:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

‘nil` results are not cached.

A cache store that uses only the record as a cache key, and ignores the user.

Since:

  • v2.3.2



21
22
23
24
# File 'lib/pundit/cache_store/legacy_store.rb', line 21

def fetch(user:, record:)
  _ = user
  @store[record] ||= yield
end