dry-transaction v0.11.0 Release Notes

Release Date: 2018-02-19 // about 6 years ago
  • โž• Added

    • ๐Ÿ‘€ Around steps, which allow control of the execution of subsequently called steps. If you know how middleware works in rack or how around callbacks can be used in RSpec, it's the same. A typical example of usage would be for DB transactions (now first class support!) or controlling side effects: rolling back the changes, cleaning garbage produced by a failed transaction, etc. See a more detailed explanation of how this works in the PR (flash-gordon in #85)
    • Broadcast when a step has started by sending the event step_called (mihairadulescu in #82)
    • โž• Add new step check that returns Success or Failure base on conditions (semenovDL in #84)
    • ๐Ÿ‘Œ Support for transaction steps without input values (GustavoCaso and timriley in #69)

    ๐Ÿ”„ Changed

    • [BREAKING] Steps no longer broadcast events with their step name followed by _success or _failure. Now, more generic names are used for the broadcast events. Before each step runs, a step event is broadcast, with the step name and its arguments. After a step runs, a step_succeeded or step_failed event is broadcast, also with the step name, the arguments and the return value (GustavoCaso in #83)
    • [BREAKING] Pub/sub support is now handled using dry-events instead of wisper. Subscriber objects should now respond to #on_step, #on_step_succeeded, or #on_step_failed to receive broadcast events (GustavoCaso in #90)
    • [BREAKING] The step adapter API has been changed in order to support around steps, although, the changes are not significant. Previously, an adapter received a step and a list of arguments for calling the operation. The list was passed as *args then you were needed to call call_operation on step and provide the list. From now on an adapter gets an operation, its options, and args (without *). operation is an ordinary callable object so a typical call is as simple as operaiton.(*args), that's it. If you want to turn your adapter into an around-like one you need to add &block parameter to the list of call arguments (e.g. def call(operation, options, args, &block)). block is responsible for calling the subsequent steps thus you can check or transform the return value and make some decisions based on it. Note capturing the block in the list of arguments is mandatory, a simple yield won't work, there are reasons, believe us. Check out the sources of around.rb for reference, it's dead simple (flash-gordon in #85)
    • โšก๏ธ Usages of the Either monad was updated with Result and its constructors. See the changes in dry-monads for more details (flash-gordon in #81)
    • ๐Ÿ’Ž Minimal Ruby version is 2.2 (flash-gordon in #72)

    ๐Ÿ›  Fixed

    • 0๏ธโƒฃ Pass arguments to a step with keyword arguments with default values (flash-gordon in #74)
    • Steps can be wrapped with private methods (semenovDL in #70)
    • ๐Ÿ‘Œ Improved error message on missing transaction step (Morozzzko in #79)

    Compare v0.10.2...v0.11.0