Module: Celluloid::FSM::ClassMethods

### Home Classes Methods

### In Files

- lib/celluloid/fsm.rb

### Methods

- #default_state
- #state
- #states

### Class/Module Index

Quicksearch

- Celluloid
- Celluloid::FSM
- Celluloid::FSM::ClassMethods
- Celluloid::FSM::State
- Celluloid::FSM::UnattachedError

No matching classes.

# Celluloid::FSM::ClassMethods

### Public Instance Methods

default_state(new_default = nil) click to toggle source

Obtain or set the default state Passing a state name sets the default state

    # File lib/celluloid/fsm.rb, line 30
    def default_state(new_default = nil)
      if new_default
        @default_state = new_default.to_sym
      else
        defined?(@default_state) ? @default_state : DEFAULT_STATE
      end
    end

state(*args, &block) click to toggle source

Declare an FSM state and optionally provide a callback block to fire Options:

- to: a state or array of states this state can transition to

    # File lib/celluloid/fsm.rb, line 46
    def state(*args, &block)
      if args.last.is_a? Hash
        # Stringify keys :/
        options = args.pop.each_with_object({}) { |(k, v), h| h[k.to_s] = v }
      else
        options = {}
      end

      args.each do |name|
        name = name.to_sym
        default_state name if options["default"]
        states[name] = State.new(name, options["to"], &block)
      end
    end

states() click to toggle source

Obtain the valid states for this FSM

    # File lib/celluloid/fsm.rb, line 39
    def states
      @states ||= {}
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.