Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πŸ‡ΊπŸ‡¦Help our brave mates in Ukraine with a donation.

dry-transaction 0.13

Wrapping operations

For transactions using operations in a container, you can wrap those operations with instance methods. This is helpful for adjusting the behavior of various operations to better suit the overall flow of your transaction.

To wrap an operation, define an instance method with the same name as a step, and call super to invoke the original operation.

class CreateUser
  include Dry::Transaction(container: Container)

  step :validate, with: "users.validate"
  step :create, with: "users.create"


  def validate(input)
    adjusted_input = upcase_values(input)

  def upcase_values(input)
    input.each_with_object({}) { |(key, value), hash|
      hash[key.to_sym] = value.upcase

create_user = "Jane", email: "")
# => Success(#<User name="JANE" email="JANE@DOE.COM">)

octocatEdit on GitHub