Class: Flor::Pro::PatGuard

Inherits:
PatContainer show all
Defined in:
lib/flor/pcore/_pat_guard.rb

Constant Summary

Constants inherited from Flor::Procedure

Flor::Procedure::RVARS, Flor::Procedure::TRUE_ATTS

Instance Attribute Summary

Attributes inherited from Node

#message

Instance Method Summary collapse

Methods inherited from PatContainer

#execute

Methods inherited from Flor::Procedure

[], core?, #debug_msg, #debug_tree, #end, #flank, #heap, inherited, make, names, #prepare_on_receive_last, #trigger_on_error

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

Instance Method Details

#execute_child(index = 0, sub = nil, h = nil) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/flor/pcore/_pat_guard.rb', line 69

def execute_child(index=0, sub=nil, h=nil)

  if @node['key'] && child_type(index) == nil
    h ||= {}
    (h['vars'] ||= {}).merge!(@node['binding'])
  end

  super(index, sub, h)
end

#pre_executeObject

“‘ _pat_guard name _pat_guard name pattern _pat_guard name conditional _pat_guard name pattern conditional _pat_guard name conditional pattern “`



18
19
20
21
22
23
24
# File 'lib/flor/pcore/_pat_guard.rb', line 18

def pre_execute

  unatt_unkeyed_children
  stringify_first_child

  @node['binding'] = {}
end

#receive_lastObject



62
63
64
65
66
67
# File 'lib/flor/pcore/_pat_guard.rb', line 62

def receive_last

  payload['_pat_binding'] = @node['binding']

  super
end

#receive_non_attObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/flor/pcore/_pat_guard.rb', line 26

def receive_non_att

  ct = child_type(@fcid)

  if ct == nil && @node['key'] == nil && payload['ret'].is_a?(String)

    k = payload['ret']

    return wrap_no_match_reply if k == '_'

    m = k.match(Flor::SPLAT_REGEX)
    k = m ? k[0] : k

    @node['key'] = k
    @node['binding'].merge!(k => val) if k != '_'

  elsif ct == nil && payload['ret'] == false

    return wrap_no_match_reply

  elsif ct == :pattern

    b = payload['_pat_binding']
    return wrap_no_match_reply unless b

    if (k = @node['key']) && (m = b['match'])
      b["#{k}__match"] = m
      b["#{k}__matched"] = val
    end

    @node['binding'].merge!(b)
  end

  super
end