Module: ActiveModel::Caching

Extended by:
ActiveSupport::Concern
Includes:
GlobalID::Identification
Defined in:
lib/active_model/caching.rb,
lib/active_model/caching/version.rb

Overview

Provides with a set of methods allowing to cache data structures at the object level

Constant Summary collapse

VERSION =
"0.1.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_storeActiveSupport::Cache::Store

Returns the cache store to use for caching attributes. Defaults to Rails.cache if Rails is defined, otherwise uses MemoryStore.

Returns:

  • (ActiveSupport::Cache::Store)

    The configured cache store



36
37
38
# File 'lib/active_model/caching.rb', line 36

def cache_store
  @cache_store ||= default_cache_store
end

.global_id_appString?

Returns the application name used for GlobalID generation. Defaults to GlobalID.app if present, then Rails.application.name if Rails is defined.

Returns:

  • (String, nil)

    The configured application name for GlobalID



44
45
46
# File 'lib/active_model/caching.rb', line 44

def global_id_app
  @global_id_app ||= default_global_id_app
end

Class Method Details

.setup {|ActiveModel::Caching| ... } ⇒ void

This method returns an undefined value.

Configures the gem with a block. Example:

ActiveModel::Caching.setup do |config|
  config.cache_store = Rails.cache
  config.global_id_app = 'MyApp'
end

Yields:



28
29
30
# File 'lib/active_model/caching.rb', line 28

def setup
  yield self
end