Forked from
PortalMEC / portalmec
2261 commits behind the upstream repository.
-
Mauricio Giacomini Girardello authoredMauricio Giacomini Girardello authored
stateful.rb 425 B
module Stateful
extend ActiveSupport::Concern
included do
# validates with accepted states
validates :state, inclusion: { in: %w(draft published suspended) }
end
def is_published?
'published' == @state
end
def is_draft?
'draft' == @state
end
def publish
@state = 'published'
end
def suspend
@state = 'suspended'
end
def is_suspended?
'suspended' == @state
end
end