Changes
0.8.0
- Add mutation testing (currently about 80% covered)
- Breaking:
Teckel::Operation::Resultno longer converts thesuccessfulvalue to a boolean. When using the default result implementation, nothing changes for you. When you manually pass anything else into it,succesful?will return this value. Thefailureandsuccessmethods work on the "Truthy" value ofsuccessfulruby result = Result.new(some_value, 42) result.successful? # => 42 - Change:
freezeing anOperationorChainwill also freeze their internal config (input, output, steps, etc.)
Internal:
- Some refactoring to cover mutations
- Extracted creating the runable
Operationinstance into a new, publicrunable(settings = UNDEFINED)method. Mainly to reduce code duplication but this also makes testing, stubbing and mocking easier.
0.7.0
- Breaking:
Teckel::Chainwill not be required by default. require manually if neededrequire "teckel/chain"[GH-24] - Breaking: Internally,
Teckel::Operation::Runnerinstead of:successand:failurenow only uses:haltas it's throw-catch symbol. [GH-26] - Add: Using the default
Teckel::Operation::Runner,input_constructorandresult_constructorwill be executed within the context of the operation instance. This allows forinput_constructorto callfail!andsuccess!without evercalling the operation. [GH-26]
0.6.0
- Breaking: Operations return values will be ignored. [GH-21]
- You'll need to use
success!orfailure! success!andfailure!are now implemented on theRunner, which makes it easier to change their behavior (including the one above).
- You'll need to use
0.5.0
- Fix: calling chain with settings and no input [GH-14]
Add: Default settings for Operation and Chains [GH-17], [GH-18]
class MyOperation include Teckel::Operation settings Struct.new(:logger) # If your settings class can cope with no input and you want to make sure # `settings` gets initialized and set. # settings will be #<struct logger=nil> default_settings! # settings will be #<struct logger=MyGlobalLogger> default_settings!(MyGlobalLogger) # settings will be #<struct logger=#<Logger:<...>> default_settings! -> { settings.new(Logger.new("/tmp/my.log")) } end
class Chain include Teckel::Chain
# set or overwrite operation settings
default_settings!(a: MyOtherLogger)
step :a, MyOperation
end
Internal:
- Move operation and chain config dsl methods into own module [GH-15]
- Code simplifications [GH-16]
## 0.4.0
- Moving verbose examples from API docs into github pages
- `#finalize!` no longer freezes the entire Operation or Chain class, only it's settings. [GH-13]
- Add simple support for using Base classes. [GH-10]
Removes global configuration `Teckel::Config.default_constructor`
```ruby
class ApplicationOperation
include Teckel::Operation
# you won't be able to overwrite any configuration in child classes,
# so take care which you want to declare
result!
settings Struct.new(:logger)
input_constructor :new
error Struct.new(:status, :messages)
def log()
return unless settings&.logger
logger <<
end
# you cannot call `finalize!` on partially declared Operations
end
- Add support for setting your own Result objects. [GH-9]
- They should include and implement
Teckel::Resultwhich is needed byChain. Chain::StepFailuregot replaced withChain::Result.- the
Teckel::Operation::Resultsmodule was removed. To let Operation use the default Result object, use the new helperresult!instead.
- They should include and implement
- Add "settings"/dependency injection to Operation and Chains. [GH-7] ```ruby MyOperation.with(logger: STDOUT).call(params)
MyChain.with(some_step: { logger: STDOUT }).call(params)
- [GH-5] Add support for ruby 2.7 pattern matching on Operation and Chain results. Both, array and hash notations are supported:
```ruby
case MyOperation.call(params)
in [false, value]
# handle failure
in [true, value]
# handle success
end
case MyChain.call(params)
in { success: false, step: :foo, value: value }
# handle foo failure
in [success: false, step: :bar, value: value }
# handle bar failure
in { success: true, value: value }
# handle success
end
- Fix setting a config twice to raise an error
0.3.0
finalize!'ing a Chain will also finalize all it's Operations- Changed attribute naming of
StepFailure:.operationwill now give the operation class of the step - was.stepbefore.stepwill now give the name of the step (which Operation failed) - was.step_namebefore
0.2.0
- Around Hooks for Chains
finalize!- freezing Chains and Operations, to prevent further changes
- Operations check their config and raise if any is missing
0.1.0
- Initial release