Class: Backyard::ModelStore
- Inherits:
-
Object
- Object
- Backyard::ModelStore
- Defined in:
- lib/backyard/model_store.rb
Instance Method Summary collapse
- #get(klass, name) ⇒ Object
- #get_collection(klass) ⇒ Object
-
#initialize ⇒ ModelStore
constructor
A new instance of ModelStore.
- #put(name, object) ⇒ Object
Constructor Details
#initialize ⇒ ModelStore
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 |