Permalink
Browse files

uses strings everywhere for node ids

  • Loading branch information...
Najaf committed Mar 2, 2013
1 parent f60c862 commit 20d5dc4c51961c4074ed81f7ff2167da4844bacb
Showing with 4 additions and 4 deletions.
  1. +3 −3 lib/dumb-answers/state.rb
  2. +1 −1 lib/dumb-answers/yaml_parser.rb
@@ -14,18 +14,18 @@ module DumbAnswers
class State
attr_accessor :nodes, :history, :current
def initialize(nodes, initial_node_id)
- @nodes, @history, @current = nodes, [], nodes[initial_node_id]
+ @nodes, @history, @current = nodes, [], nodes[initial_node_id.to_s]
end
def answer!(question_id, answer_code)
- @history << [question_id, answer_code]
+ @history << [question_id.to_s, answer_code.to_s]
# determine the applicable transitions by evaluating
# the history against a list of possible transitions from
# the current node
applicable_transitions = @current.transitions.select do |transition|
transition['conditions'].each_pair.all? do |question_id, answer_code|
- @history.include? [question_id, answer_code]
+ @history.include? [question_id.to_s, answer_code.to_s]
end
end
@@ -7,7 +7,7 @@ module YamlParser
def self.load(data)
data.reduce({}) do |memo, node|
- memo[node['id']] = TYPES[node['type']].new(node)
+ memo[node['id'].to_s] = TYPES[node['type']].new(node)
memo
end
end

0 comments on commit 20d5dc4

Please sign in to comment.