Class: Machinist::Caching::Warehouse
- Inherits:
-
Object
- Object
- Machinist::Caching::Warehouse
- Defined in:
- lib/machinist/caching/warehouse.rb
Overview
A Warehouse is a hash supports lists as keys.
It's used for storing cached objects created by Machinist::Caching::Shop.
warehouse[klass, attributes] = object
warehouse[klass, attributes] # => object
Instance Attribute Summary collapse
-
#shelf ⇒ Object
Returns the value of attribute shelf.
Instance Method Summary collapse
-
#[](klass, attributes) ⇒ Object
Return the value for the given list of keys.
-
#[]=(klass, attributes, object) ⇒ Object
Assign a value for the given list of keys.
-
#initialize ⇒ Warehouse
constructor
:nodoc:.
Constructor Details
#initialize ⇒ Warehouse
:nodoc:
12 13 14 |
# File 'lib/machinist/caching/warehouse.rb', line 12 def initialize #:nodoc: self.shelf = Hash.new{|hash, key| hash[key] = {}} end |
Instance Attribute Details
#shelf ⇒ Object
Returns the value of attribute shelf.
10 11 12 |
# File 'lib/machinist/caching/warehouse.rb', line 10 def shelf @shelf end |
Instance Method Details
#[](klass, attributes) ⇒ Object
Return the value for the given list of keys.
22 23 24 |
# File 'lib/machinist/caching/warehouse.rb', line 22 def [](klass, attributes) shelf[klass][attributes] end |
#[]=(klass, attributes, object) ⇒ Object
Assign a value for the given list of keys.
17 18 19 |
# File 'lib/machinist/caching/warehouse.rb', line 17 def []=(klass, attributes, object) shelf[klass][attributes] = object end |