1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/HOWTO_MIGRATE_FROM_AASM_3_TO_4.md
2013-11-30 15:15:09 +01:00

887 B

How to migrate from AASM version 3 to 4?

callback arguments

On one hand, when using callbacks like this

class MyClass
  aasm do
    ...
    event :close, :before => :before do
      transitions :to => :closed, :from => :open, :on_transition => :transition_proc
    end
  end
  def transition_proc(arg1, arg2); end
  def before(arg1, arg2); end
  ...
end

you don't have to provide the target state as first argument anymore. So, instead of

my_class = MyClass.new
my_class.close(:closed, arg1, arg2)

you can leave that away now

my_class.close(arg1, args)

On the other hand, you have to accept the arguments for all callback methods (and procs) you provide and use. If you don't want to provide these, you can splat them

def before(*args); end
# or
def before(*_); end # to indicate that you don't want to use the arguments