-
-
Save anonymous/1dad37a79cc123d87b3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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