Module: Origin::Extensions::Object

Defined in:
lib/origin/extensions/object.rb

Overview

This module contains additional object behaviour.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Object) __add__(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.

Since:

  • 1.0.0



18
19
20
# File 'lib/origin/extensions/object.rb', line 18

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

- (Array) __add_from_array__(array)

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__add_from_array__([ 1, 2 ])

Parameters:

  • value (Array)

    The array to add to.

Returns:

  • (Array)

    The merged object.

Since:

  • 1.0.0



32
33
34
# File 'lib/origin/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.

Since:

  • 1.0.0



125
126
127
# File 'lib/origin/extensions/object.rb', line 125

def __array__
  [ self ]
end

- (Object) __deep_copy__

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

Examples:

Deep copy the object.

1.__deep_copy__

Returns:

Since:

  • 1.0.0



115
# File 'lib/origin/extensions/object.rb', line 115

def __deep_copy__; self; end

- (Object) __expand_complex__

Get the object as expanded.

Examples:

Get the object expanded.

obj.__expand_complex__

Returns:

Since:

  • 1.0.5



137
138
139
# File 'lib/origin/extensions/object.rb', line 137

def __expand_complex__
  self
end

- (Array) __intersect__(object)

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.

Since:

  • 1.0.0



46
47
48
# File 'lib/origin/extensions/object.rb', line 46

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

- (Array) __intersect_from_array__(array)

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__intersect_from_array__([ 1, 2 ])

Parameters:

  • value (Array)

    The array to intersect to.

Returns:

  • (Array)

    The merged object.

Since:

  • 1.0.0



60
61
62
# File 'lib/origin/extensions/object.rb', line 60

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

- (Array) __intersect_from_object__(object)

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__intersect_from_object__([ 1, 2 ])

Parameters:

  • value (Object)

    The value to intersect to.

Returns:

  • (Array)

    The merged object.

Since:

  • 1.0.0



74
75
76
# File 'lib/origin/extensions/object.rb', line 74

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

- (Array) __union__(object)

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.

Since:

  • 1.0.0



88
89
90
# File 'lib/origin/extensions/object.rb', line 88

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

- (Array) __union_from_object__(object)

Merge this object into the provided array.

Examples:

Merge the object into the array.

4.__union_from_object__([ 1, 2 ])

Parameters:

  • value (Object)

    The value to union to.

Returns:

  • (Array)

    The merged object.

Since:

  • 1.0.0



102
103
104
# File 'lib/origin/extensions/object.rb', line 102

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

- (false) regexp?

Is the object a regex.

Examples:

Is the object a regex?

obj.regexp?

Returns:

  • (false)

    Always false.

Since:

  • 1.0.4



149
150
151
# File 'lib/origin/extensions/object.rb', line 149

def regexp?
  false
end