Sha256: c9eec9879a858a857b9649b01fb381b2e12dd05a12aa611944514d05495aacb0
Contents?: true
Size: 908 Bytes
Versions: 76
Compression:
Stored size: 908 Bytes
Contents
module Dynflow module Stateful def self.included(base) base.extend ClassMethods end module ClassMethods def states raise NotImplementedError end def state_transitions raise NotImplementedError end end def states self.class.states end def state_transitions self.class.state_transitions end attr_reader :state def state=(state) set_state state, false end def set_state(state, skip_transition_check) state = state.to_sym if state.is_a?(String) && states.map(&:to_s).include?(state) raise "unknown state #{state}" unless states.include? state unless self.state.nil? || skip_transition_check || state_transitions.fetch(self.state).include?(state) raise "invalid state transition #{self.state} >> #{state} in #{self}" end @state = state end end end
Version data entries
76 entries across 76 versions & 1 rubygems