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_field_namesObject



73
74
75
# File 'lib/interface.rb', line 73

def state_fu_field_names
  @_state_fu_field_names ||= {}
end

#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.


66
67
68
69
70
# File 'lib/interface.rb', line 66

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



77
78
79
# File 'lib/interface.rb', line 77

def state_fu_machines
  @_state_fu_machines ||= {}
end