class BehaveFun::TaskBuilderFactory::Builder
Attributes
control[R]
factory[R]
Public Class Methods
new(factory, control)
click to toggle source
# File lib/behave_fun/task_builder_factory.rb, line 84 def initialize(factory, control) @factory = factory @control = control end
Public Instance Methods
add_task(type, params = {}, &block)
click to toggle source
# File lib/behave_fun/task_builder_factory.rb, line 89 def add_task(type, params = {}, &block) task = type.new(params) @control.add_child(task) if block builder = Builder.new(factory, task) builder.instance_eval(&block) end end
build_from_hash(task_hash)
click to toggle source
# File lib/behave_fun/task_builder_factory.rb, line 110 def build_from_hash(task_hash) type_name, params, guard_with, children = task_hash.values_at(:type, :params, :guard_with, :children) params ||= {} children ||= [] type = factory.tasks[type_name.to_sym] add_task type, **params do guard_with { build_from_hash(guard_with) } if guard_with children.each { build_from_hash(_1) } end end
guard_with(&block)
click to toggle source
# File lib/behave_fun/task_builder_factory.rb, line 99 def guard_with(&block) builder = Builder.new(factory, Tree.new) builder.instance_eval(&block) control.guard = builder.control.root end
include(task)
click to toggle source
# File lib/behave_fun/task_builder_factory.rb, line 105 def include(task) cloned_task = task.dup @control.add_child(cloned_task) end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/behave_fun/task_builder_factory.rb, line 122 def method_missing(name, *args, &block) type = factory.tasks[name.to_sym] if type add_task(type, *args, &block) else super end end