class Flor::Pro::Apply

Public Instance Methods

pre_execute() click to toggle source
# File lib/flor/pcore/apply.rb, line 65
def pre_execute

  @node['atts'] = []
end
receive() click to toggle source
Calls superclass method Flor::Procedure#receive
# File lib/flor/pcore/apply.rb, line 70
def receive

  return wrap_reply if from && from == @node['applied']

  super
end
receive_last() click to toggle source
# File lib/flor/pcore/apply.rb, line 86
def receive_last

  do_apply
end
receive_last_att() click to toggle source
Calls superclass method Flor::Procedure#receive_last_att
# File lib/flor/pcore/apply.rb, line 77
def receive_last_att

  return do_apply unless tree[1][@ncid]

  rewrite_block_into_function

  super
end

Protected Instance Methods

do_apply() click to toggle source
# File lib/flor/pcore/apply.rb, line 93
def do_apply

  args = @node['atts']
  nht = @node['heat']

  src =
    Flor.is_proc_tree?(nht) && nht[1]['proc'] == 'apply' ?
    args.shift[1] :
    nht

  args << [ 'yield', payload_ret ] \
    if ! from_att? && Flor.is_func_tree?(payload_ret)

  ms = apply(src, args, tree[2])

  @node['applied'] = ms.first['nid']

  ms
end
rewrite_block_into_function() click to toggle source
# File lib/flor/pcore/apply.rb, line 113
def rewrite_block_into_function

  t = tree
  cn = t[1][@ncid..-1]
  c0 = cn[0]

  return if cn.size == 1 && %w[ def fun ].include?(c0[0])
    #
    # if the single child is a "def" or "fun", no need to rewrite,
    # that single child function becomes the block

  bt = [ 'def', cn, t[2] ]
  t[1] = (@fcid ? t[1][0..@fcid] : []) + [ bt ]

  @node['tree'] = t
end