These are chat archives for dry-rb/chat
Types::Strict::Symbol.enum( 1 => :time_interval, 2 => :distance_interval, 4 => :treshold_distance, 8 => :on_change, 16 => :total )
Hi, what’s the best way in dry/transaction to deal with steps that require input from a previous step. Let’s say I have a simplified transaction with multiple steps:
Dry.Transaction(container: some_container) do map :build # builds or finds an object and changes some attributes try :persist # persists the object AR save! tee :send_notification # Send notification email tee :track # Log: Object X Created / Updated (if it was a new record or not) end
I am not sure what’s the best approach here.
What do you guys think is the best way to deal with cases like this?
[object, object.new_recrod?]. But I don’t know, it feels a little bit strange.
is_new_record = object.new_record? object.save! [object, is_new_record]
foo_wasomg is it a thing?
decorate it. Just wrap it in another object?
class Result < SimpleDelegator attr_reader :operation def initialize(result, operation) super(result) @operation = operation end end Result.new('result', :create)
OpenStruct.new(result: object, operation: :create)