class Volt::Persistors::Store

Public Class Methods

new(model, tasks = nil) click to toggle source
# File lib/volt/models/persistors/store.rb, line 9
def initialize(model, tasks = nil)
  @tasks = tasks
  @model = model

  @saved = false
end

Public Instance Methods

clear_identity_map() click to toggle source
# File lib/volt/models/persistors/store.rb, line 40
def clear_identity_map
  @@identity_map.clear
end
inspect() click to toggle source
# File lib/volt/models/persistors/store.rb, line 44
def inspect
  "<#{self.class}:#{object_id}>"
end
read_new_model(method_name) click to toggle source

On stores, we store the model so we don't have to look it up every time we do a read.

# 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.
  options = @model.options.merge(parent: @model, path: @model.path + [method_name])
  if method_name.plural?
    model = @model.new_array_model([], options)
  else
    options[:persistor] = @model.persistor
    model= @model.new_model(nil, options)

    # TODO: Might not need to assign this
    @model.attributes ||= {}
    @model.attributes[method_name] = model
  end

  model
end
saved?() click to toggle source
# File lib/volt/models/persistors/store.rb, line 16
def saved?
  @saved
end