class InfoparkComponentCache::Component
@author Tomasz Przedmojski <tomasz.przedmojski@infopark.de>
Cache entity (component) consists of an obj, a name and some parameters (hash). It should be used to point to some data stored in a particular context
Attributes
component[R]
obj[R]
params[R]
Public Class Methods
new(obj, component, params = {})
click to toggle source
# File lib/infopark_component_cache/component.rb, line 10 def initialize(obj, component, params = {}) @obj = obj @component = component @params = params end
Public Instance Methods
cache_key(meta_prefix = nil)
click to toggle source
# File lib/infopark_component_cache/component.rb, line 20 def cache_key(meta_prefix = nil) if meta_prefix meta_prefix + "_" + KeyGenerator.generate_key(identity_hash) else KeyGenerator.generate_key(identity_hash) end end
identity_hash()
click to toggle source
# File lib/infopark_component_cache/component.rb, line 28 def identity_hash @params .except(:obj) # avoid the (ruby) object_id as part of the cache key (to_s), because it will change for each request .merge({ obj_name: @obj.name, obj_id: @obj.id, obj_component: @component }) end
name()
click to toggle source
# File lib/infopark_component_cache/component.rb, line 16 def name component end