Class: DataMapper::Query::Conditions::AbstractOperation

Inherits:
Object
  • Object
show all
Extended by:
Equalizer
Includes:
Enumerable
Defined in:
lib/dm-core/query/conditions/operation.rb

Overview

class Operation

Direct Known Subclasses

AndOperation, NotOperation, NullOperation, OrOperation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Equalizer

equalize

Instance Attribute Details

#operandsObject (readonly)

TODO: document



48
49
50
# File 'lib/dm-core/query/conditions/operation.rb', line 48

def operands
  @operands
end

Class Method Details

.descendantsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: document



52
53
54
# File 'lib/dm-core/query/conditions/operation.rb', line 52

def self.descendants
  @descendants ||= Set.new
end

.inherited(operation_class) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: document



58
59
60
# File 'lib/dm-core/query/conditions/operation.rb', line 58

def self.inherited(operation_class)
  descendants << operation_class
end

.slug(slug = nil) ⇒ Object

TODO: document



64
65
66
# File 'lib/dm-core/query/conditions/operation.rb', line 64

def self.slug(slug = nil)
  slug ? @slug = slug : @slug
end

Instance Method Details

#<<(operand) ⇒ Object

TODO: document



98
99
100
101
# File 'lib/dm-core/query/conditions/operation.rb', line 98

def <<(operand)
  @operands << operand
  self
end

#eachObject

TODO: document



80
81
82
# File 'lib/dm-core/query/conditions/operation.rb', line 80

def each
  @operands.each { |*block_args| yield(*block_args) }
end

#inspectObject

TODO: document



105
106
107
# File 'lib/dm-core/query/conditions/operation.rb', line 105

def inspect
  "#<#{self.class} @operands=#{@operands.inspect}>"
end

#slugSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the comparison class slug

Returns:

  • (Symbol)

    the comparison class slug



74
75
76
# File 'lib/dm-core/query/conditions/operation.rb', line 74

def slug
  self.class.slug
end

#sorted_operandsArray<AbstractOperation>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a list of operands in predictable order

Returns:



115
116
117
# File 'lib/dm-core/query/conditions/operation.rb', line 115

def sorted_operands
  @operands.sort_by { |operand| operand.hash }
end

#valid?Boolean

TODO: document

Returns:

  • (Boolean)


86
87
88
89
90
91
92
93
94
# File 'lib/dm-core/query/conditions/operation.rb', line 86

def valid?
  operands.any? && operands.all? do |operand|
    if operand.respond_to?(:valid?)
      operand.valid?
    else
      true
    end
  end
end