Method: Asynchro::State#initialize

Defined in:
lib/asynchro/state.rb

#initialize(&block) ⇒ State

Create a state map object. If a block is given, it is called with the instance created, then that instance is run.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/asynchro/state.rb', line 4

def initialize(&block)
  @states = {
    :finish => [ ]
  }
  
  if (block_given?)
    case (block.arity)
    when 0
      instance_exec(&block)
    else
      block.call(self)
    end
  
    self.run!
  end
end