class Flor::Pro::Max

Public Instance Methods

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

  @node['atts'] = []
  @node['ret'] ||= receive_payload_ret

  unatt_unkeyed_children
end
receive_last() click to toggle source
# File lib/flor/pcore/max.rb, line 24
def receive_last

  ret = @node['ret']

  fail Flor::FlorError.new(
    "found no argument that can #{@node['heap']}", self
  ) unless ret

  lax = att('lax', 'loose') == true
  types = ret.collect { |e| Flor.type(e) }

  ret = ret.collect { |x| JSON.dump(x) } if lax && types != [ 'number' ]

  r =
    begin
      ret.send(@node['heap'])
    rescue
      fail unless lax
      nil
    end
  res =
    r ?
    @node['ret'][ret.index { |e| e == r }] :
    nil

  wrap_reply('ret' => res)
end
receive_payload_ret() click to toggle source
# File lib/flor/pcore/max.rb, line 15
def receive_payload_ret

  case ret = payload['ret']
  when Array then ret
  when Hash then ret.values
  else false
  end
end