Class: Volt::Persistors::Store
- Defined in:
- lib/volt/models/persistors/store.rb
Direct Known Subclasses
Constant Summary collapse
- @@identity_map =
ModelIdentityMap.new
Instance Method Summary collapse
- #clear_identity_map ⇒ Object
-
#initialize(model, tasks = nil) ⇒ Store
constructor
A new instance of Store.
- #inspect ⇒ Object
-
#read_new_model(method_name) ⇒ Object
On stores, we store the model so we don’t have to look it up every time we do a read.
- #saved? ⇒ Boolean
Methods inherited from Base
#added, #async?, #auto_generate_id, #changed, #clear, #event_added, #event_removed, #loaded, #removed, #root_model
Constructor Details
#initialize(model, tasks = nil) ⇒ Store
Returns a new instance of Store.
9 10 11 12 13 14 |
# File 'lib/volt/models/persistors/store.rb', line 9 def initialize(model, tasks = nil) @tasks = tasks @model = model @saved = false end |
Instance Method Details
#clear_identity_map ⇒ Object
40 41 42 |
# File 'lib/volt/models/persistors/store.rb', line 40 def clear_identity_map @@identity_map.clear end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/volt/models/persistors/store.rb', line 44 def inspect "<#{self.class}:#{object_id}>" end |
#read_new_model(method_name) ⇒ Object
On stores, we store the model so we don’t have to look it up every time we do a read.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/volt/models/persistors/store.rb', line 22 def read_new_model(method_name) # On stores, plural associations are automatically assumed to be # collections. = @model..merge(parent: @model, path: @model.path + [method_name]) if method_name.plural? model = @model.new_array_model([], ) else [:persistor] = @model.persistor model= @model.new_model(nil, ) # TODO: Might not need to assign this @model.attributes ||= {} @model.attributes[method_name] = model end model end |
#saved? ⇒ Boolean
16 17 18 |
# File 'lib/volt/models/persistors/store.rb', line 16 def saved? @saved end |