Module: Perimeter::Repository::Adapters::Abstract::ClassMethods
- Defined in:
- lib/perimeter/repository/adapters/abstract.rb
Instance Method Summary collapse
-
#create(attributes) ⇒ Object
Returns an Operation instance that MUST hold an Entity as object.
-
#create!(id) ⇒ Object
Returns an Entity or raises a CreationError.
-
#destory!(id) ⇒ Object
Returns true or raises a DestructionError.
-
#destroy(id) ⇒ Object
Returns an Operation instance that SHOULD hold the destroyed Entity as object.
-
#find(id) ⇒ Object
Returns an Operation instance that MUST hold an Entity as object.
-
#find!(id) ⇒ Object
Returns an Entity or raises a FindingError.
-
#update(id, attributes) ⇒ Object
Returns an Operation instance that MAY hold an Entity as object.
Instance Method Details
#create(attributes) ⇒ Object
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.
25 26 27 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 25 def create(attributes) raise NotImplementedError end |
#create!(id) ⇒ Object
Returns an Entity or raises a CreationError.
54 55 56 57 58 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 54 def create!(id) operation = create id raise ::Perimeter::Repository::CreationError, operation..exception if operation.failure? operation.object end |
#destory!(id) ⇒ Object
Returns true or raises a DestructionError.
62 63 64 65 66 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 62 def destory!(id) operation = destroy id raise ::Perimeter::Repository::DestructionError, operation..exception if operation.failure? true end |
#destroy(id) ⇒ Object
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.
40 41 42 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 40 def destroy(id) raise NotImplementedError end |
#find(id) ⇒ Object
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.
17 18 19 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 17 def find(id) raise NotImplementedError end |
#find!(id) ⇒ Object
Returns an Entity or raises a FindingError.
46 47 48 49 50 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 46 def find!(id) operation = find id raise ::Perimeter::Repository::FindingError, operation..exception if operation.failure? operation.object end |
#update(id, attributes) ⇒ Object
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.
33 34 35 |
# File 'lib/perimeter/repository/adapters/abstract.rb', line 33 def update(id, attributes) raise NotImplementedError end |