module Perimeter::Repository::Adapters::Abstract::ClassMethods

Public Instance Methods

create(attributes) click to toggle source

Returns an Operation instance that MUST hold an Entity as object. Success is defined as “there was no record and now there is one”, everything else is a failure. Validations are run on the Record.

# File lib/perimeter/repository/adapters/abstract.rb, line 25
def create(attributes)
  raise NotImplementedError
end
create!(id) click to toggle source

Returns an Entity or raises a CreationError.

# File lib/perimeter/repository/adapters/abstract.rb, line 54
def create!(id)
  operation = create id
  raise ::Perimeter::Repository::CreationError, operation.meta.exception if operation.failure?
  operation.object
end
destory!(id) click to toggle source

Returns true or raises a DestructionError.

# File lib/perimeter/repository/adapters/abstract.rb, line 62
def destory!(id)
  operation = destroy id
  raise ::Perimeter::Repository::DestructionError, operation.meta.exception if operation.failure?
  true
end
destroy(id) click to toggle source

Returns an Operation instance that SHOULD hold the destroyed Entity as object. Success is defined as “after this operation the record is or already was gone”, everything else is a failure.

# File lib/perimeter/repository/adapters/abstract.rb, line 40
def destroy(id)
  raise NotImplementedError
end
find(id) click to toggle source

Returns an Operation instance that MUST hold an Entity as object. Success is defined as “the record could be found”, everything else is a failure. If the record does not exist, there is no Trouble. Any other StandardError notifies Trouble.

# File lib/perimeter/repository/adapters/abstract.rb, line 17
def find(id)
  raise NotImplementedError
end
find!(id) click to toggle source

Returns an Entity or raises a FindingError.

# File lib/perimeter/repository/adapters/abstract.rb, line 46
def find!(id)
  operation = find id
  raise ::Perimeter::Repository::FindingError, operation.meta.exception if operation.failure?
  operation.object
end
update(id, attributes) click to toggle source

Returns an Operation instance that MAY hold an Entity as object. Success is defined as “there was a record and now some/all attributes have been updated”, everything else is a failure. NOTE: Whether validations are run on the Record first is backend specific.

# File lib/perimeter/repository/adapters/abstract.rb, line 33
def update(id, attributes)
  raise NotImplementedError
end