Module: Statum::ClassMethods

Defined in:
lib/statum/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#state_machinesArray<Statum::Machine>

Returns defined state machines

Returns:



18
19
20
# File 'lib/statum/class_methods.rb', line 18

def state_machines
  instance_variable_get(STATE_MACHINES_VARIABLE) || []
end

#statum(field, options = {}, &block) ⇒ Object

Define new state machine

Parameters:

  • field (Symbol)

    Field to store state

  • options (Hash) (defaults to: {})

    Options

  • block (Block)

    Bloc with DSL

Options Hash (options):

  • initial (Symbol)

    Initial value



9
10
11
12
13
# File 'lib/statum/class_methods.rb', line 9

def statum(field, options = {}, &block)
  definer = Statum::StateDefiner.new(self, field, options)
  definer.instance_eval(&block) if block_given?
  add_machine(definer.state_machine)
end