Module: StateFu::Blueprint

Defined in:
lib/blueprint.rb

Class Method Summary collapse

Class Method Details

.load_yaml(yaml) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/blueprint.rb', line 4

def self.load_yaml(yaml)
  hash = YAML.load(yaml) 
  returning Machine.new(hash[:options] || {}) do |machine|
    add_states machine, hash
    add_events machine, hash
    hash[:requirement_messages] &&
      hash[:requirement_messages].each { |k, v| machine.requirement_messages[k] = v } 
    hash[:initial_state] &&
      machine.initial_state = hash[:initial_state] 
    # TODO tools, helpers here
  end
end

.to_yaml(machine) ⇒ Object



17
18
19
# File 'lib/blueprint.rb', line 17

def self.to_yaml(machine)
  to_hash(machine).to_yaml
end