Speaking the Lingo

Building a Workflow DSL

RouteState = OpenStruct.new
RouteState.queues = Hash.new

def route(name)
  RouteState.route = Route.new(name)
  yield if block_given?
end  

def step(name)
  RouteState.step = Step.new(intern_queue(name))
  RouteState.route.add(RouteState.step)
  yield if block_given?
end

def on(code, options)
  step = Route.find(options[:route], options[:step])
  alt = Alternative.new(code, step)
  RouteState.step.add(alt)
end