Class: DataMapper::Query::Conditions::NotOperation
- Inherits:
-
AbstractOperation
- Object
- AbstractOperation
- DataMapper::Query::Conditions::NotOperation
- Defined in:
- lib/dm-core/query/conditions/operation.rb
Overview
class OrOperation
Instance Attribute Summary
Attributes inherited from AbstractOperation
Instance Method Summary collapse
-
#<<(operand) ⇒ self
Add an operand to the operation.
-
#matches?(record) ⇒ true
Match the record.
-
#minimize ⇒ self, ...
Minimize the operation.
-
#negated? ⇒ Boolean
private
Test if the operation is negated.
-
#operand ⇒ AbstractOperation, ...
Return the only operand in the operation.
-
#to_s ⇒ String
Return the string representation of the operation.
Methods inherited from AbstractOperation
#clear, descendants, #difference, #each, #empty?, #first, inherited, #intersection, #merge, #one?, #slug, slug, #sorted_operands, #union, #valid?
Methods included from Equalizer
Methods included from Assertions
Instance Method Details
#<<(operand) ⇒ self
Add an operand to the operation
This will only allow a single operand to be added.
560 561 562 563 564 |
# File 'lib/dm-core/query/conditions/operation.rb', line 560 def <<(operand) assert_one_operand(operand) assert_no_self_reference(operand) super end |
#matches?(record) ⇒ true
Match the record
544 545 546 547 |
# File 'lib/dm-core/query/conditions/operation.rb', line 544 def matches?(record) operand = self.operand operand.respond_to?(:matches?) ? !operand.matches?(record) : true end |
#minimize ⇒ self, ...
Minimize the operation
584 585 586 587 588 589 590 591 |
# File 'lib/dm-core/query/conditions/operation.rb', line 584 def minimize minimize_operands prune_operands # factor out double negatives if possible operand = self.operand one? && instance_of?(operand.class) ? operand.operand : self end |
#negated? ⇒ Boolean
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.
Test if the operation is negated
Defaults to return false.
611 612 613 614 |
# File 'lib/dm-core/query/conditions/operation.rb', line 611 def negated? parent = self.parent parent ? !parent.negated? : true end |
#operand ⇒ AbstractOperation, ...
Return the only operand in the operation
572 573 574 |
# File 'lib/dm-core/query/conditions/operation.rb', line 572 def operand first end |
#to_s ⇒ String
Return the string representation of the operation
599 600 601 |
# File 'lib/dm-core/query/conditions/operation.rb', line 599 def to_s empty? ? '' : "NOT(#{operand.to_s})" end |