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

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

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.



425
426
427
428
429
430
431
# File 'lib/dm-core/query/conditions/operation.rb', line 425

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