Class: FSM::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/fsm/builder.rb

Overview

Builder exposees ‘only’ (well there are some other methods exposed) the methods that are required to build the configuration

Instance Method Summary collapse

Constructor Details

#initialize(target_class) ⇒ Builder

Create a new Builder which creates a Machine for the target_class



11
12
13
14
# File 'lib/fsm/builder.rb', line 11

def initialize(target_class)
  @target_class = target_class
  @machine = Machine.new(target_class)
end

Instance Method Details

#process(&block) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/fsm/builder.rb', line 16

def process(&block)
  raise ArgumentError.new('Block expected') unless block_given?
  self.instance_eval(&block)
  @machine.build_transition_methods
  @machine
end