Class: Flor::Procedure
- Inherits:
-
Node
- Object
- Node
- Flor::Procedure
show all
- Defined in:
- lib/flor/core/procedure.rb
Direct Known Subclasses
Macro, Flor::Pro::Abort, Flor::Pro::Andor, Flor::Pro::Apply, Flor::Pro::Arith, Flor::Pro::ArrayQmark, Flor::Pro::Atom, Flor::Pro::Att, Flor::Pro::Break, Flor::Pro::Cancel, Flor::Pro::Case, Flor::Pro::Cmp, Flor::Pro::Coll, Flor::Pro::Concurrence, Flor::Pro::ConcurrentIterator, Flor::Pro::Cond, Flor::Pro::Cursor, Flor::Pro::Define, Flor::Pro::Dmute, Flor::Pro::Dol, Flor::Pro::DoubleQuoteString, Flor::Pro::Dump, Flor::Pro::Echo, Flor::Pro::Empty, Flor::Pro::Err, Flor::Pro::Fail, Flor::Pro::Flatten, Flor::Pro::Graft, Flor::Pro::Head, Flor::Pro::If, Flor::Pro::Includes, Flor::Pro::Iterator, Flor::Pro::Keys, Flor::Pro::Length, Flor::Pro::Matchr, Flor::Pro::Max, Flor::Pro::Merge, Flor::Pro::Move, Flor::Pro::NoEval, Flor::Pro::NoRet, Flor::Pro::Not, Flor::Pro::OnCancel, Flor::Pro::OnError, Flor::Pro::OnReceive, Flor::Pro::OnTimeout, Flor::Pro::Part, Flor::Pro::PatContainer, Flor::Pro::Push, Flor::Pro::Rand, Flor::Pro::Range, Flor::Pro::Ref, Flor::Pro::RegularExpressionString, Flor::Pro::Return, Flor::Pro::Reverse, Flor::Pro::Schedule, Flor::Pro::Sequence, Flor::Pro::Set, Flor::Pro::Shuffle, Flor::Pro::Signal, Flor::Pro::Skip, Flor::Pro::Sleep, Flor::Pro::Slice, Flor::Pro::Sort, Flor::Pro::Split, Flor::Pro::Stall, Flor::Pro::Strings, Flor::Pro::Task, Flor::Pro::TimeStamp, Flor::Pro::ToArray, Flor::Pro::Trace, Flor::Pro::Trap, Flor::Pro::Twig, Flor::Pro::TypeOf, Flor::Pro::UnderscoreApply, Flor::Pro::Until, Flor::Pro::Val
Constant Summary
collapse
- RVARS =
“Returning vars” variables to pass back to pass upon reply. In the ‘receive’ messages, it’s a hash under the key ‘rvars’.
%w[ idx ].freeze
- TRUE_ATTS =
Attributes that when given alone are turned to “true” attributes.
For example ‘sequence flank` gets turned to `sequence flank: true`
The transformation occurs in Flor::Pro::Att (“_att”).
%w[ flank off disabled ].freeze
Instance Attribute Summary
Attributes inherited from Node
#message
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#child_id, #cnodes, #cnodes_any?, #cnodes_empty?, #deref, #descendant_of?, #domain, #exid, #fei, #from, #h, #initialize, #lookup_tree, #lookup_value, #message_or_node_payload, #nid, #node_closed?, #node_ended?, #node_open?, #node_payload, #node_payload_ret, #node_status, #node_status_flavour, #on_error_parent, #parent, #payload, #payload_ret, #point, #reheap, #to_procedure_node, #tree
Constructor Details
This class inherits a constructor from Flor::Node
Class Method Details
.[](name) ⇒ Object
25
26
27
28
|
# File 'lib/flor/core/procedure.rb', line 25
def [](name)
@@inherited.find { |k| k.names && k.names.include?(name) }
end
|
.core? ⇒ Boolean
44
|
# File 'lib/flor/core/procedure.rb', line 44
def core?; @core; end
|
.inherited(subclass) ⇒ Object
20
21
22
23
|
# File 'lib/flor/core/procedure.rb', line 20
def inherited(subclass)
(@@inherited ||= []) << subclass
end
|
.make(executor, node, message) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/flor/core/procedure.rb', line 46
def make(executor, node, message)
heap = node['heap']
heac = self[heap]
fail NameError.new("unknown procedure #{heap.inspect}") \
unless heac
heac.new(executor, node, message)
end
|
.names(*names) ⇒ Object
Also known as:
name
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/flor/core/procedure.rb', line 30
def names(*names)
@names = [] unless defined?(@names)
if (names = names.flatten).any?
@names = names
@core = !! caller.find { |l| l.match(/flor\/pcore/) }
end
@names
end
|
Instance Method Details
#debug_msg(msg = message) ⇒ Object
103
104
105
106
|
# File 'lib/flor/core/procedure.rb', line 103
def debug_msg(msg=message)
puts Flor.detail_msg(@executor, msg)
end
|
#debug_tree(nid = nil) ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/flor/core/procedure.rb', line 95
def debug_tree(nid=nil)
nid ||= self.nid
tree = lookup_tree(nid)
puts Flor.tree_to_s(tree, nid)
end
|
#end ⇒ Object
108
109
110
111
|
# File 'lib/flor/core/procedure.rb', line 108
def end
end_node
end
|
#flank ⇒ Object
113
114
115
116
117
118
119
|
# File 'lib/flor/core/procedure.rb', line 113
def flank
@node['tree'] = Flor.dup(tree)
@node['replyto'] = nil
wrap('nid' => parent, 'flavour' => 'flank')
end
|
#heap ⇒ Object
121
|
# File 'lib/flor/core/procedure.rb', line 121
def heap; @node['heap']; end
|
#pre_execute ⇒ Object
58
59
60
61
|
# File 'lib/flor/core/procedure.rb', line 58
def pre_execute
end
|
#prepare_on_receive_last(on_x, max = -1)) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/flor/core/procedure.rb', line 63
def prepare_on_receive_last(on_x, max=-1)
on_x
.inject([]) { |a, (criteria, mop)|
next a if max > 0 && a.size >= max
next a unless match_on?(criteria)
msg = Flor.dup(@message)
a.concat(
if Flor.is_message?(mop)
[ Flor.dup(mop).merge!('msg' => msg) ]
else args = [ [ 'msg', msg ], [ 'err', msg['error'] ] ]
apply(mop, args, mop[2])
end) }
end
|
#trigger_on_error ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/flor/core/procedure.rb', line 82
def trigger_on_error
@message['on_error'] = true
close_node('on-error')
@node['on_receive_last'] =
prepare_on_receive_last(@node['on_error'], 1)
do_wrap_cancel_children ||
do_receive end
|