Class: InfoparkComponentCache::Component
- Inherits:
-
Object
- Object
- InfoparkComponentCache::Component
- Defined in:
- lib/infopark_component_cache/component.rb
Overview
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
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #cache_key(meta_prefix = nil) ⇒ Object
- #identity_hash ⇒ Object
-
#initialize(obj, component, params = {}) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(obj, component, params = {}) ⇒ Component
Returns a new instance of Component.
10 11 12 |
# File 'lib/infopark_component_cache/component.rb', line 10 def initialize(obj, component, params={}) @obj, @component, @params = obj, component, params end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/infopark_component_cache/component.rb', line 8 def name @name end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
8 9 10 |
# File 'lib/infopark_component_cache/component.rb', line 8 def obj @obj end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/infopark_component_cache/component.rb', line 8 def params @params end |
Instance Method Details
#cache_key(meta_prefix = nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/infopark_component_cache/component.rb', line 14 def cache_key(=nil) if + "_" + KeyGenerator.generate_key(identity_hash) else KeyGenerator.generate_key(identity_hash) end end |
#identity_hash ⇒ Object
22 23 24 |
# File 'lib/infopark_component_cache/component.rb', line 22 def identity_hash @params.merge({:obj_name=>@obj.name, :obj_id=>@obj.id, :obj_component=>@component}) end |