Skip to content

Instantly share code, notes, and snippets.

/test.rb Secret

Created July 9, 2015 20:11
Show Gist options
  • Save anonymous/1dad37a79cc123d87b3f to your computer and use it in GitHub Desktop.
Save anonymous/1dad37a79cc123d87b3f to your computer and use it in GitHub Desktop.
module StateMachineConcern
extend ActiveSupport::Concern
included do |base|
state_machine_class.states.each do |state|
# do something with each state
end
end
class_methods do
def transition_class
raise NotImplementedError
end
def state_machine_class
raise NotImplementedError
end
def initial_state
state_machine_class.initial_state
end
end
end
class MyModel < ActiveRecord::Base
def self.transition_class
MyModelTransitionClass
end
def self.state_machine_class
MyModelStateMachineClass
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment