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
-
#state_fu_machine(*args, &block) ⇒ Object
(also: #machine)
Given no arguments, return the default machine (:state_fu) for the class, creating it if it did not exist.
- #state_fu_machines ⇒ Object (also: #machines)
- #state_fu_options ⇒ Object
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 ) = args..symbolize_keys! name = args[0] || DEFAULT StateFu::Machine.for_class( self, name, , &block ) end |
#state_fu_machines ⇒ Object Also known as: machines
75 76 77 |
# File 'lib/interface.rb', line 75 def state_fu_machines @_state_fu_machines ||= {} end |
#state_fu_options ⇒ Object
71 72 73 |
# File 'lib/interface.rb', line 71 def @_state_fu_options ||= {} end |