module Mongoid::Criteria::Queryable::Extensions::Object
This module contains additional object behavior.
Public Instance Methods
Combine the two objects using the add strategy.
@example Add the object to the array.
[ 1, 2, 3 ].__add__(4)
@param [ Object
] object The object to add.
@return [ Object
] The result of the add.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 22 def __add__(object) (object == self) ? self : [ self, object ].flatten.uniq end
Merge this object into the provided array.
@example Merge the object into the array.
4.__add_from_array__([ 1, 2 ])
@param [ Array
] array The array to add to.
@return [ Array
] The merged object.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 36 def __add_from_array__(array) array.concat(Array(self)).uniq end
Get the object as an array.
@example Get the object as an array.
4.__array__
@return [ Array
] The wrapped object.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 129 def __array__ [ self ] end
Deep copy the object. This is for API compatibility, but needs to be overridden.
@example Deep copy the object.
1.__deep_copy__
@return [ Object
] self.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 119 def __deep_copy__; self; end
Get the object as expanded.
@example Get the object expanded.
obj.__expand_complex__
@return [ Object
] self.
@since 1.0.5
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 141 def __expand_complex__ self end
Combine the two objects using the intersect strategy.
@example Add the object to the array.
[ 1, 2, 3 ].__intersect__(4)
@param [ Object
] object The object to intersect.
@return [ Array
] The result of the intersect.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 50 def __intersect__(object) object.__intersect_from_object__(self) end
Merge this object into the provided array.
@example Merge the object into the array.
4.__intersect_from_array__([ 1, 2 ])
@param [ Array
] array The array to intersect to.
@return [ Array
] The merged object.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 64 def __intersect_from_array__(array) array & Array(self) end
Merge this object into the provided array.
@example Merge the object into the array.
4.__intersect_from_object__([ 1, 2 ])
@param [ Object
] object The value to intersect to.
@return [ Array
] The merged object.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 78 def __intersect_from_object__(object) Array(object) & Array(self) end
Combine the two objects using the union strategy.
@example Add the object to the array.
[ 1, 2, 3 ].__union__(4)
@param [ Object
] object The object to union.
@return [ Array
] The result of the union.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 92 def __union__(object) object.__union_from_object__(self) end
Merge this object into the provided array.
@example Merge the object into the array.
4.__union_from_object__([ 1, 2 ])
@param [ Object
] object The value to union to.
@return [ Array
] The merged object.
@since 1.0.0
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 106 def __union_from_object__(object) (Array(object) + Array(self)).uniq end
Is the object a regex.
@example Is the object a regex?
obj.regexp?
@return [ false ] Always false.
@since 1.0.4
# File lib/mongoid/criteria/queryable/extensions/object.rb, line 153 def regexp? false end