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

- (true) matches?(record)

Match the record



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

- (self, ...) minimize

Minimize the operation



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

- (Boolean) valid?

Test if the operation is valid

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



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

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