Class: DataMapper::Query::Conditions::OrOperation

Inherits:
AbstractOperation show all
Includes:
FlattenOperation
Defined in:
lib/dm-core/query/conditions/operation.rb

Instance Attribute Summary

Attributes inherited from AbstractOperation

#operands, #parent

Instance Method Summary collapse

Methods included from FlattenOperation

#<<

Methods inherited from AbstractOperation

#<<, #clear, descendants, #difference, #each, #empty?, #first, inherited, #intersection, #merge, #negated?, #one?, #slug, slug, #sorted_operands, #to_s, #union

Methods included from Equalizer

#equalize

Methods included from Assertions

#assert_kind_of

Instance Method Details

#matches?(record) ⇒ boolean

Match the record

Parameters:

  • record (Resource, Hash)

    the resource to match

Returns:

  • (boolean)

    true if the record matches, false if not



491
492
493
# File 'lib/dm-core/query/conditions/operation.rb', line 491

def matches?(record)
  any? { |op| op.respond_to?(:matches?) ? op.matches?(record) : true }
end

#minimizeself, ...

Minimize the operation

Returns:



515
516
517
518
519
520
521
522
523
# File 'lib/dm-core/query/conditions/operation.rb', line 515

def minimize
  minimize_operands

  return Operation.new(:null) if any?(&:nil?)

  prune_operands

  one? ? first : self
end

#valid?Boolean

Test if the operation is valid

An OrOperation is valid if one of it’s operands is valid.

Returns:

  • (Boolean)

    true if the operation is valid, false if not



503
504
505
# File 'lib/dm-core/query/conditions/operation.rb', line 503

def valid?
  any? { |op| valid_operand?(op) }
end