'vermont' end end user = User.new(state: 'maine') user.lives_in_awesome_state? # => false user = User.new(state: 'vermont') user.lives_in_awesome_state? # => true
state == 'maine' end end user = User.new(state: 'maine') user.lives_in_awesome_state? # => true user = User.new(state: 'vermont') user.lives_in_awesome_state? # => true
create app/enums create app/enums/state.rb class State < ClassyEnum::Base end class State::Connecticut < State end class State::Maine < State end class State::Massachusetts < State end ...
:parked do after_transition :on => :crash, :do => :tow after_transition :on => :repair, :do => :fix after_transition any => :parked do |vehicle, transition| vehicle.seatbelt_on = false end end end