Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Transactions

Adam Wead edited this page Sep 11, 2018 · 1 revision

CHO uses dry-transactions to organize and perform actions on the various components of the system.

Practices

While dry-transactions has a very general purpose use, we employ some basic principles and practices when we implement them:

  • a single "transaction" encompasses multiple operations
  • operations can used across different transactions
  • operations can be used alone, outside of a transaction, but usually are not
  • operations have no opinions or knowledge about the other operations that occur before and after them
  • an operation returns either a Success or Failure object
  • a Failure is usually returned when an error is rescued, but it doesn't have to be (see the Import::Validate operation)
  • a Success is returned when the operation is performed successfully, without any errors
  • multiple success and failure paths may exist within a single operation
  • a Success can be similar to a guard clause, which passes along the arguments received by the operation to the next operation, without performing any actions (see the File::Save and Import::Work operations)