module Rmodel::RepositoryExt::Sugarable

Public Instance Methods

find!(id) click to toggle source
# File lib/rmodel/repository_ext/sugarable.rb, line 4
def find!(id)
  find(id) or raise(Rmodel::NotFound.new(self, id: id))
end
insert(*args) click to toggle source
# File lib/rmodel/repository_ext/sugarable.rb, line 8
def insert(*args)
  if args.length == 1
    if args.first.is_a?(Array)
      insert_array(args.first)
    else
      insert_one(args.first)
    end
  else
    insert_array(args)
  end
end
save(object) click to toggle source
# File lib/rmodel/repository_ext/sugarable.rb, line 20
def save(object)
  if object.id.nil?
    insert_one(object)
  else
    update(object)
  end
end

Private Instance Methods

insert_array(array) click to toggle source
# File lib/rmodel/repository_ext/sugarable.rb, line 30
def insert_array(array)
  array.each { |object| insert_one(object) }
end