Class: Backyard::ModelStore

Inherits:
Object
  • Object
show all
Defined in:
lib/backyard/model_store.rb

Instance Method Summary collapse

Constructor Details

#initializeModelStore

Returns a new instance of ModelStore.



4
5
6
# File 'lib/backyard/model_store.rb', line 4

def initialize
  @store ||= {}
end

Instance Method Details

#get(klass, name) ⇒ Object



13
14
15
16
17
18
# File 'lib/backyard/model_store.rb', line 13

def get(klass, name)
  models = @store[klass]
  unless models.nil?
    models[name]
  end
end

#get_collection(klass) ⇒ Object



20
21
22
# File 'lib/backyard/model_store.rb', line 20

def get_collection(klass)
  @store[klass] || []
end

#put(name, object) ⇒ Object



8
9
10
11
# File 'lib/backyard/model_store.rb', line 8

def put(name, object)
  @store[object.class] ||= {}
  @store[object.class][name] = object
end