Add an operand to the operation
This will only allow a single operand to be added.
@param [AbstractOperation, AbstractComparison, Array] operand
the operand to add
@return [self]
the operation
@api semipublic
# File lib/dm-core/query/conditions/operation.rb, line 560 560: def <<(operand) 561: assert_one_operand(operand) 562: assert_no_self_reference(operand) 563: super 564: end
Match the record
@param [Resource, Hash] record
the resource to match
@return [true]
true if the record matches, false if not
@api semipublic
# File lib/dm-core/query/conditions/operation.rb, line 544 544: def matches?(record) 545: operand = self.operand 546: operand.respond_to?(:matches?) ? !operand.matches?(record) : true 547: end
Minimize the operation
@return [self]
the minimized NotOperation
@return [AbstractOperation, AbstractComparison, Array]
the minimized operation
@api semipublic
# File lib/dm-core/query/conditions/operation.rb, line 584 584: def minimize 585: minimize_operands 586: prune_operands 587: 588: # factor out double negatives if possible 589: operand = self.operand 590: one? && instance_of?(operand.class) ? operand.operand : self 591: end
Test if the operation is negated
Defaults to return false.
@return [Boolean]
true if the operation is negated, false if not
@api private
# File lib/dm-core/query/conditions/operation.rb, line 611 611: def negated? 612: parent = self.parent 613: parent ? !parent.negated? : true 614: end
Return the only operand in the operation
@return [AbstractOperation, AbstractComparison, Array]
the operand
@api semipublic
# File lib/dm-core/query/conditions/operation.rb, line 572 572: def operand 573: first 574: end
Assert the operand is not equal to self
@param [AbstractOperation, AbstractComparison, Array] operand
the operand to test
@return [undefined]
@raise [ArgumentError]
raised if object is appended to itself
@api private
# File lib/dm-core/query/conditions/operation.rb, line 646 646: def assert_no_self_reference(operand) 647: if equal?(operand) 648: raise ArgumentError, 'cannot append operand to itself' 649: end 650: end
Assert there is only one operand
@param [AbstractOperation, AbstractComparison, Array] operand
the operand to test
@return [undefined]
@raise [ArgumentError]
raised if the operand is not a valid type
@api private
# File lib/dm-core/query/conditions/operation.rb, line 629 629: def assert_one_operand(operand) 630: unless empty? || self.operand == operand 631: raise ArgumentError, "#{self.class} cannot have more than one operand" 632: end 633: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.