lib/volt/models/buffer.rb
# Returns a buffered version of the model
Returns a buffered version of the model
Returns a buffered version of the model
def buffer
      model_path = options[:path]
      if model_path.last.plural? && model_path[-1] != :[]
        model_klass = class_at_path(model_path + [:[]])
      else
        model_klass = class_at_path(model_path)
      end
      new_options = options.merge(path: model_path, save_to: self).reject { |k, _| k.to_sym == :persistor }
      model       = model_klass.new({}, new_options, :loading)
      if state == :loaded
        setup_buffer(model)
      else
        parent.then do
          setup_buffer(model)
        end
      end
      model
    end
def buffer model_path = options [ :path ] if model_path . last . plural? && model_path [ - 1 ] != :[] model_klass = class_at_path ( model_path + [ :[] ] ) else model_klass = class_at_path ( model_path ) end new_options = options . merge ( path : model_path , save_to : self ) . reject { | k , _ | k . to_sym == :persistor } model = model_klass . new ( { } , new_options , :loading ) if state == :loaded setup_buffer ( model ) else parent . then do setup_buffer ( model ) end end model end
Returns a buffered version of the model
Returns a buffered version of the model
# When we grab a buffer off of a plual class (subcollection), we get it as a model.