module Aquam::MachineClassMethods

Public Instance Methods

attribute(name = nil) click to toggle source
# File lib/aquam/machine_class_methods.rb, line 5
def attribute(name = nil)
  name ? @attribute = name : @attribute ||= :state
end
event(name, &block) click to toggle source
# File lib/aquam/machine_class_methods.rb, line 21
def event(name, &block)
  Aquam::EventTransitions.new self, name, &block
end
events() click to toggle source
# File lib/aquam/machine_class_methods.rb, line 13
def events
  @event ||= Hash.new { |hash, key| hash[key] = {} }
end
state(name, klass) click to toggle source
# File lib/aquam/machine_class_methods.rb, line 17
def state(name, klass)
  states[name] = klass
end
states() click to toggle source
# File lib/aquam/machine_class_methods.rb, line 9
def states
  @states ||= {}
end
transition(from, to, event_name) click to toggle source
# File lib/aquam/machine_class_methods.rb, line 25
def transition(from, to, event_name)
  fail Aquam::InvalidStateError if !valid_state?(from) || !valid_state?(to)

  events[event_name][from] = to
end
valid_event?(event) click to toggle source
# File lib/aquam/machine_class_methods.rb, line 35
def valid_event?(event)
  events.keys.include? event
end
valid_state?(state) click to toggle source
# File lib/aquam/machine_class_methods.rb, line 31
def valid_state?(state)
  states.keys.include? state
end