class Flor::Pro::Cancel

Public Instance Methods

pre_execute() click to toggle source

ruote had “undo” as well…

# File lib/flor/punit/cancel.rb, line 46
def pre_execute

  @node['atts'] = []
end
receive_last() click to toggle source
# File lib/flor/punit/cancel.rb, line 51
def receive_last

  targets =
    @node['atts']
      .select { |k, _| k == nil }
      .inject([]) { |a, (_, v)|
        v = Array(v)
        a.concat(v) if v.all? { |e| e.is_a?(String) }
        a } +
    att_a('nid') +
    att_a('ref')

  nids, tags = targets.partition { |t| Flor.is_nid?(t) }
  nids += tags_to_nids(tags)
  nids = nids.uniq

  fla = heap

  messages = nids
    .collect { |nid| wrap_cancel('nid' => nid, 'flavour' => fla)[0] }

  messages = messages + wrap_reply \
    unless nids.find { |nid| is_ancestor_node?(nid) }

  messages
end