Module: DataMapper::Query::Conditions::FlattenOperation

Included in:
AndOperation, OrOperation
Defined in:
lib/dm-core/query/conditions/operation.rb

Overview

class AbstractOperation

Instance Method Summary collapse

Instance Method Details

#<<(operand) ⇒ self

Add an operand to the operation, flattening the same types

Flattening means that if the operand is the same as the operation, we should just include the operand’s operands in the operation and prune that part of the tree. This results in a shallower tree, is faster to match and usually generates more efficient queries in the adapters.

Parameters:

Returns:

  • (self)

    the operation



431
432
433
434
435
436
437
# File 'lib/dm-core/query/conditions/operation.rb', line 431

def <<(operand)
  if kind_of?(operand.class)
    merge(operand.operands)
  else
    super
  end
end