Class: Machinist::Caching::Warehouse

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeWarehouse

: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

#shelfObject

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