123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Criteria::Queryable::Extensions::Object

Relationships & Source Files
Namespace Children
Modules:
Defined in: lib/mongoid/criteria/queryable/extensions/object.rb

Overview

Adds query type-casting behavior to Object class.

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#regexp?false (readonly)

Deprecated.

Is the object a regex.

Examples:

Is the object a regex?

obj.regexp?

Returns:

  • (false)

    Always false.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 132

def regexp?
  false
end

Instance Method Details

#__add__(object) ⇒ Object

Combine the two objects using the add strategy.

Examples:

Add the object to the array.

[ 1, 2, 3 ].__add__(4)

Parameters:

  • object (Object)

    The object to add.

Returns:

  • (Object)

    The result of the add.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 20

def __add__(object)
  (object == self) ? self : [ self, object ].flatten.uniq
end

#__add_from_array__(array) ⇒ Array

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__add_from_array__([ 1, 2 ])

Parameters:

  • array (Array)

    The array to add to.

Returns:

  • (Array)

    The merged object.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 32

def __add_from_array__(array)
  array.concat(Array(self)).uniq
end

#__array__Array

Get the object as an array.

Examples:

Get the object as an array.

4.__array__

Returns:

  • (Array)

    The wrapped object.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 111

def __array__
  [ self ]
end

#__deep_copy__Object

Deep copy the object. This is for API compatibility, but needs to be overridden.

Examples:

Deep copy the object.

1.__deep_copy__

Returns:

  • (Object)

    self.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 103

def __deep_copy__; self; end

#__expand_complex__Object

Get the object as expanded.

Examples:

Get the object expanded.

obj.__expand_complex__

Returns:

  • (Object)

    self.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 121

def __expand_complex__
  self
end

#__intersect__(object) ⇒ Array

Combine the two objects using the intersect strategy.

Examples:

Add the object to the array.

[ 1, 2, 3 ].__intersect__(4)

Parameters:

  • object (Object)

    The object to intersect.

Returns:

  • (Array)

    The result of the intersect.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 44

def __intersect__(object)
  object.__intersect_from_object__(self)
end

#__intersect_from_array__(array) ⇒ Array

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__intersect_from_array__([ 1, 2 ])

Parameters:

  • array (Array)

    The array to intersect to.

Returns:

  • (Array)

    The merged object.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 56

def __intersect_from_array__(array)
  array & Array(self)
end

#__intersect_from_object__(object) ⇒ Array

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__intersect_from_object__([ 1, 2 ])

Parameters:

  • object (Object)

    The value to intersect to.

Returns:

  • (Array)

    The merged object.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 68

def __intersect_from_object__(object)
  Array(object) & Array(self)
end

#__union__(object) ⇒ Array

Combine the two objects using the union strategy.

Examples:

Add the object to the array.

[ 1, 2, 3 ].__union__(4)

Parameters:

  • object (Object)

    The object to union.

Returns:

  • (Array)

    The result of the union.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 80

def __union__(object)
  object.__union_from_object__(self)
end

#__union_from_object__(object) ⇒ Array

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__union_from_object__([ 1, 2 ])

Parameters:

  • object (Object)

    The value to union to.

Returns:

  • (Array)

    The merged object.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/object.rb', line 92

def __union_from_object__(object)
  (Array(object) + Array(self)).uniq
end