Class: DataMapper::Query::Conditions::AbstractOperation
- Inherits:
-
Object
- Object
- DataMapper::Query::Conditions::AbstractOperation
- Extended by:
- Equalizer
- Includes:
- Enumerable
- Defined in:
- lib/dm-core/query/conditions/operation.rb
Overview
class Operation
Direct Known Subclasses
Instance Attribute Summary collapse
-
#operands ⇒ Object
readonly
TODO: document.
Class Method Summary collapse
-
.descendants ⇒ Object
private
TODO: document.
-
.inherited(operation_class) ⇒ Object
private
TODO: document.
-
.slug(slug = nil) ⇒ Object
TODO: document.
Instance Method Summary collapse
-
#<<(operand) ⇒ Object
TODO: document.
-
#each ⇒ Object
TODO: document.
-
#inspect ⇒ Object
TODO: document.
-
#slug ⇒ Symbol
private
Return the comparison class slug.
-
#sorted_operands ⇒ Array<AbstractOperation>
private
Return a list of operands in predictable order.
-
#valid? ⇒ Boolean
TODO: document.
Methods included from Equalizer
Instance Attribute Details
#operands ⇒ Object (readonly)
TODO: document
48 49 50 |
# File 'lib/dm-core/query/conditions/operation.rb', line 48 def operands @operands end |
Class Method Details
.descendants ⇒ 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
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 |
#each ⇒ Object
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 |
#inspect ⇒ Object
TODO: document
105 106 107 |
# File 'lib/dm-core/query/conditions/operation.rb', line 105 def inspect "#<#{self.class} @operands=#{@operands.inspect}>" end |
#slug ⇒ Symbol
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
74 75 76 |
# File 'lib/dm-core/query/conditions/operation.rb', line 74 def slug self.class.slug end |
#sorted_operands ⇒ Array<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
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
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 |