Module: Flows::Plugin::OutputContract
- Defined in:
- lib/flows/plugin/output_contract.rb,
lib/flows/plugin/output_contract/dsl.rb,
lib/flows/plugin/output_contract/errors.rb,
lib/flows/plugin/output_contract/wrapper.rb
Overview
Allows to make a contract check and transformation for #call
method execution in any class.
Plugin applies a wrapper to a #call
instance method.
This wrapper will do the following:
- check that Result instance is returned by
#call
- check that returned Result#status is expected
- check that returned result data conforms Contract assigned to a particular result type and status
- applies contract transform to the returned data
- returns Result with the same status and type, wraps transformed data inside.
Plugin provides DSL to express expected result statuses and assigned contracts. Contracts definition reuses Contract.make to execute block and get a contract.
success_with(status, &block)
- defines contract for a successful result with statusstatus
.failure_with(status, &block)
- defines contract for a failure result with statusstatus
.skip_output_contract
- disables contract check and transformation for current class and children.
Defined Under Namespace
Modules: DSL, Wrapper Classes: ContractError, Error, NoContractError, ResultTypeError, StatusError
Class Method Summary collapse
- .included(mod) ⇒ Object private