Module: DeepCover::Node::Mixin::FlowAccounting
- Defined in:
- lib/deep_cover/node/mixin/flow_accounting.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#child_flow_entry_count(child, _name = nil) ⇒ Object
Returns the number of time the control flow entered this child_node.
-
#executable? ⇒ Boolean
Returns true iff it is executable.
-
#execution_count ⇒ Object
Returns number of times the node itself was “executed”.
-
#flow_completion_count ⇒ Object
Returns the number of times the control flow succesfully left the node.
-
#flow_entry_count ⇒ Object
Returns the control flow entered the node.
-
#flow_interrupt_count ⇒ Object
Returns the number of times it changed the usual control flow (e.g. raised, returned, …) Implementation: This is always deduced; Nodes should not override.
-
#was_executed? ⇒ Boolean
Returns true iff it is executable and if was successfully executed.
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 6 def self.included(base) base.has_child_handler('%{name}_flow_entry_count') end |
Instance Method Details
#child_flow_entry_count(child, _name = nil) ⇒ Object
Returns the number of time the control flow entered this child_node. This is the responsability of the Node, not of the child. Must be refined if the parent node may have an impact on control flow (raising, branching, …)
54 55 56 57 58 59 60 61 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 54 def child_flow_entry_count(child, _name = nil) prev = child.previous_sibling if prev prev.flow_completion_count else flow_entry_count end end |
#executable? ⇒ Boolean
Returns true iff it is executable. Keywords like ‘end` are not executable, but literals like `42` are executable.
32 33 34 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 32 def executable? true end |
#execution_count ⇒ Object
Returns number of times the node itself was “executed”. Definition of executed depends on the node. For now at least, don’t return ‘nil`, instead return `false` in `executable?`
38 39 40 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 38 def execution_count flow_entry_count end |
#flow_completion_count ⇒ Object
Returns the number of times the control flow succesfully left the node. This is the responsability of the child Node, never of the parent. Must be refined if the child node may have an impact on control flow (raising, branching, …)
45 46 47 48 49 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 45 def flow_completion_count last = children_nodes_in_flow_order.last return last.flow_completion_count if last flow_entry_count end |
#flow_entry_count ⇒ Object
Returns the control flow entered the node. The control flow can then either complete normally or be interrupted
Implementation: This is always the responsibility of the parent; Nodes should not override.
19 20 21 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 19 def flow_entry_count parent.child_flow_entry_count(self) end |
#flow_interrupt_count ⇒ Object
Returns the number of times it changed the usual control flow (e.g. raised, returned, …) Implementation: This is always deduced; Nodes should not override.
25 26 27 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 25 def flow_interrupt_count flow_entry_count - flow_completion_count end |
#was_executed? ⇒ Boolean
Returns true iff it is executable and if was successfully executed
11 12 13 |
# File 'lib/deep_cover/node/mixin/flow_accounting.rb', line 11 def was_executed? execution_count > 0 end |