module Origin::Extensions::Object

This module contains additional object behaviour.

Public Instance Methods

__add__(object) click to toggle source

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/origin/extensions/object.rb, line 17
def __add__(object)
  (object == self) ? self : [ self, object ].flatten.uniq
end
__add_from_array__(array) click to toggle source

Merge this object into the provided array.

@example Merge the object into the array.

4.__add_from_array__([ 1, 2 ])

@param [ Array ] value The array to add to.

@return [ Array ] The merged object.

@since 1.0.0

# File lib/origin/extensions/object.rb, line 31
def __add_from_array__(array)
  array.concat(Array(self)).uniq
end
__array__() click to toggle source

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/origin/extensions/object.rb, line 124
def __array__
  [ self ]
end
__deep_copy__() click to toggle source

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/origin/extensions/object.rb, line 114
def __deep_copy__; self; end
__expand_complex__() click to toggle source

Get the object as expanded.

@example Get the object expanded.

obj.__expand_complex__

@return [ Object ] self.

@since 1.0.5

# File lib/origin/extensions/object.rb, line 136
def __expand_complex__
  self
end
__intersect__(object) click to toggle source

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/origin/extensions/object.rb, line 45
def __intersect__(object)
  object.__intersect_from_object__(self)
end
__intersect_from_array__(array) click to toggle source

Merge this object into the provided array.

@example Merge the object into the array.

4.__intersect_from_array__([ 1, 2 ])

@param [ Array ] value The array to intersect to.

@return [ Array ] The merged object.

@since 1.0.0

# File lib/origin/extensions/object.rb, line 59
def __intersect_from_array__(array)
  array & Array(self)
end
__intersect_from_object__(object) click to toggle source

Merge this object into the provided array.

@example Merge the object into the array.

4.__intersect_from_object__([ 1, 2 ])

@param [ Object ] value The value to intersect to.

@return [ Array ] The merged object.

@since 1.0.0

# File lib/origin/extensions/object.rb, line 73
def __intersect_from_object__(object)
  Array(object) & Array(self)
end
__union__(object) click to toggle source

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/origin/extensions/object.rb, line 87
def __union__(object)
  object.__union_from_object__(self)
end
__union_from_object__(object) click to toggle source

Merge this object into the provided array.

@example Merge the object into the array.

4.__union_from_object__([ 1, 2 ])

@param [ Object ] value The value to union to.

@return [ Array ] The merged object.

@since 1.0.0

# File lib/origin/extensions/object.rb, line 101
def __union_from_object__(object)
  (Array(object) + Array(self)).uniq
end
regexp?() click to toggle source

Is the object a regex.

@example Is the object a regex?

obj.regexp?

@return [ false ] Always false.

@since 1.0.4

# File lib/origin/extensions/object.rb, line 148
def regexp?
  false
end