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

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

Overview

class AndOperation

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) ⇒ true

Match the record

Parameters:

  • record (Resource, Hash)

    the resource to match

Returns:

  • (true)

    true if the record matches, false if not



498
499
500
# File 'lib/dm-core/query/conditions/operation.rb', line 498

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

#minimizeself, ...

Minimize the operation

Returns:



522
523
524
525
526
527
528
529
530
# File 'lib/dm-core/query/conditions/operation.rb', line 522

def minimize
  minimize_operands

  return Operation.new(:null) if any? { |op| op.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



510
511
512
# File 'lib/dm-core/query/conditions/operation.rb', line 510

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