How to pass args passed to an event to the error block with aasm?

612 views Asked by At

My event is defined this way:

event :share, after: :inc_in_path_share do
      transitions from: :bucketed, to: :shared
      error do |e|
        inc_share(message, tags)
      end
    end

and I call it my_instance.share(message, tags). If the transition is allowed, I don't have problem to call inc_in_path_share with message and tags. But when the transition is not allowed, I want to have a default action processed by inc_share in my error block.

How to pass message and tags to the error block ? May be the way I am thinking it is not the best too (XY problem). Thanks !

1

There are 1 answers

0
alto On

Jonathan Pares created a ticket for this on AASM's github page (see https://github.com/aasm/aasm/issues/196). I (maintainer of AASM) will implement this feature.