Class: BehaveFun::Tree

Inherits:
Task
  • Object
show all
Defined in:
lib/behave_fun/tree.rb

Instance Attribute Summary collapse

Attributes inherited from Task

#children, #context, #control, #guard, #params, #status

Instance Method Summary collapse

Methods inherited from Task

#cancel, #cancelled?, #ended?, #fail, #failed?, #fresh?, #guard_passed?, #initialize, #run, #running, #running?, #start, #succeeded?, #success, task_name

Methods included from TaskSerializer

#name, #serializable_status_fields

Constructor Details

This class inherits a constructor from BehaveFun::Task

Instance Attribute Details

#rootObject

Returns the value of attribute root.



3
4
5
# File 'lib/behave_fun/tree.rb', line 3

def root
  @root
end

Instance Method Details

#add_child(child) ⇒ Object

tree does not have children, it only contains a root



36
37
38
# File 'lib/behave_fun/tree.rb', line 36

def add_child(child)
  self.root = child
end

#as_jsonObject



45
46
47
48
49
50
# File 'lib/behave_fun/tree.rb', line 45

def as_json
  {
    version: 1,
    root: root.as_json
  }
end

#child_failObject



31
32
33
# File 'lib/behave_fun/tree.rb', line 31

def child_fail
  fail
end

#child_runningObject



23
24
25
# File 'lib/behave_fun/tree.rb', line 23

def child_running
  running
end

#child_successObject



27
28
29
# File 'lib/behave_fun/tree.rb', line 27

def child_success
  success
end

#context=(context) ⇒ Object



14
15
16
17
# File 'lib/behave_fun/tree.rb', line 14

def context=(context)
  @context = context
  @root.context = context
end

#dump_statusObject



52
53
54
# File 'lib/behave_fun/tree.rb', line 52

def dump_status
  root.dump_status
end

#dupObject



60
61
62
63
64
# File 'lib/behave_fun/tree.rb', line 60

def dup
  cloned = self.class.new(params)
  cloned.root = root.dup
  cloned
end

#executeObject



19
20
21
# File 'lib/behave_fun/tree.rb', line 19

def execute
  root.run
end

#resetObject



40
41
42
43
# File 'lib/behave_fun/tree.rb', line 40

def reset
  super
  root.reset
end

#restore_status(data) ⇒ Object



56
57
58
# File 'lib/behave_fun/tree.rb', line 56

def restore_status(data)
  root.restore_status(data)
end

#treeObject



10
11
12
# File 'lib/behave_fun/tree.rb', line 10

def tree
  self
end