Custom helper methods of State Machine (ruby) by releu

757fb0d5ec7560b6f25f5bd98eadc020?size=52

I have a lot of code in my project like the following:

class Animal < ActiveRecord::Base
  state_machine do
    around_transition :on => :sure do |animal, _, block|
      animal.transaction do
        block.call
        animal.do_things_on_sure
      end
    end
  end
end

around_transition looks ugly and repeats for many classes.. Lets refactor it. More under the cut