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

- (Object) state_fu_machine(*args, &block) 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

- (Object) state_fu_machines Also known as: machines



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

def state_fu_machines
  @_state_fu_machines ||= {}
end

- (Object) state_fu_options



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

def state_fu_options
  @_state_fu_options ||= {}
end