Class: DataMapper::Query::Conditions::AndOperation

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

Overview

module FlattenOperation

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, #valid?

Methods included from Equalizer

#equalize

Methods included from Assertions

#assert_kind_of

Instance Method Details

#matches?(record) ⇒ true

Match the record

Examples:

with a Hash

operation.matches?({ :id => 1 })  # => true

with a Resource

operation.matches?(Blog::Article.new(:id => 1))  # => true

Parameters:

  • record (Resource, Hash)

    the resource to match

Returns:

  • (true)

    true if the record matches, false if not



460
461
462
# File 'lib/dm-core/query/conditions/operation.rb', line 460

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

#minimizeself, ...

Minimize the operation

Returns:



472
473
474
475
476
477
478
479
480
# File 'lib/dm-core/query/conditions/operation.rb', line 472

def minimize
  minimize_operands

  return Operation.new(:null) if any? && all? { |op| op.nil? }

  prune_operands

  one? ? first : self
end