Module: Cell::Caching

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/cell/caching.rb

Defined Under Namespace

Modules: ClassMethods, Notifications

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) cache_configured=(value) (writeonly)

Sets the attribute cache_configured

Parameters:

  • value

    the value to set the attribute cache_configured to.



59
60
61
# File 'lib/cell/caching.rb', line 59

def cache_configured=(value)
  @cache_configured = value
end

- (Object) cache_store

we want to use DI to set a cache store in cell/rails.



61
62
63
# File 'lib/cell/caching.rb', line 61

def cache_store
  @cache_store
end

Instance Method Details

- (Boolean) cache?(state, *args)

Returns:

  • (Boolean)


63
64
65
# File 'lib/cell/caching.rb', line 63

def cache?(state, *args)
  cache_configured? and state_cached?(state) and self.class.conditional_procs[state].evaluate(self, *args)
end

- (Boolean) cache_configured?

Returns:

  • (Boolean)


56
57
58
# File 'lib/cell/caching.rb', line 56

def cache_configured?
  @cache_configured
end

- (Object) render_state(state, *args)



47
48
49
50
51
52
53
54
# File 'lib/cell/caching.rb', line 47

def render_state(state, *args)
  return super(state, *args) unless cache?(state, *args)

  key     = self.class.state_cache_key(state, self.class.version_procs[state].evaluate(self, *args))
  options = self.class.cache_options.eval(state, self, *args)

  fetch_from_cache_for(key, options) { super(state, *args) }
end