class NoLeftJoinNoise

Removes the noise generated by left joins that were not join.

i.e. x is removed in { x: { id: nil, name: nil, … } }

Supported heuristics are:

Constants

REMOVERS

Attributes

remover[R]

Public Class Methods

new(remover) click to toggle source
Calls superclass method
# File lib/bmg/operator/autowrap.rb, line 217
def self.new(remover)
  return remover if remover.is_a?(NoLeftJoinNoise)
  super
end
new(remover) click to toggle source
# File lib/bmg/operator/autowrap.rb, line 222
def initialize(remover)
  @remover_to_s = remover
  @remover = case remover
  when NilClass then REMOVERS[:none]
  when Proc     then remover
  when Symbol   then REMOVERS[remover]
  when Hash     then ->(t,k){ REMOVERS[remover[k] || :none].call(t,k) }
  else
    raise "Invalid remover `#{remover}`"
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/bmg/operator/autowrap.rb, line 257
def ==(other)
  other.is_a?(NoLeftJoinNoise) && remover.eql?(other.remover)
end
all_nil?(tuple) click to toggle source
# File lib/bmg/operator/autowrap.rb, line 243
def all_nil?(tuple)
  return false unless tuple.is_a?(Hash)
  tuple.all?{|(k,v)| v.nil? || all_nil?(tuple[k]) }
end
call(tuple) click to toggle source
# File lib/bmg/operator/autowrap.rb, line 235
def call(tuple)
  tuple.each_key do |k|
    call(tuple[k]) if tuple[k].is_a?(Hash)
    @remover.call(tuple, k) if tuple[k].is_a?(Hash) && all_nil?(tuple[k])
  end
  tuple
end
hash() click to toggle source
# File lib/bmg/operator/autowrap.rb, line 253
def hash
  remover.hash
end
inspect() click to toggle source
# File lib/bmg/operator/autowrap.rb, line 248
def inspect
  @remover_to_s.inspect
end
Also aliased as: to_s
to_s()
Alias for: inspect