Module: StateFu::Interface::ClassMethods

Defined in:
lib/interface.rb

Overview

Provides access to StateFu to your classes. Plenty of aliases are provided so you can use whatever makes sense to you.

Instance Method Summary collapse

Instance Method Details

#state_fu_machine(*args, &block) ⇒ Object Also known as: machine

Given no arguments, return the default machine (:state_fu) for the class, creating it if it did not exist.

Given a symbol, return the machine by that name, creating it if it didn't exist, and definining it if a block is passed.

Given a block, apply it to a StateFu::Lathe to define a machine, and return it.

This can be done multiple times; changes are cumulative.

You can have as many machines as you like per class.

Klass.machine # the default machine named :om # equivalent to Klass.machine(:om) Klass.machine(:workflow) # another totally separate machine

recognised options are: :field_name - specify the field to use for persistence. defaults to machine_name_field.



64
65
66
67
68
# File 'lib/interface.rb', line 64

def state_fu_machine( *args, &block )
  options = args.extract_options!.symbolize_keys!
  name    = args[0] || DEFAULT
  StateFu::Machine.for_class( self, name, options, &block )
end

#state_fu_machinesObject Also known as: machines



75
76
77
# File 'lib/interface.rb', line 75

def state_fu_machines
  @_state_fu_machines ||= {}
end

#state_fu_optionsObject



71
72
73
# File 'lib/interface.rb', line 71

def state_fu_options
  @_state_fu_options ||= {}
end