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)
-
- (Object) __add__(object)
Combine the two objects using the add strategy.
-
- (Array) __add_from_array__(array)
Merge this object into the provided array.
-
- (Array) __array__
Get the object as an array.
-
- (Object) __deep_copy__
Deep copy the object.
-
- (Array) __intersect__(object)
Combine the two objects using the intersect strategy.
-
- (Array) __intersect_from_array__(array)
Merge this object into the provided array.
-
- (Array) __intersect_from_object__(object)
Merge this object into the provided array.
-
- (Array) __union__(object)
Combine the two objects using the union strategy.
-
- (Array) __union_from_object__(object)
Merge this object into the provided array.
- - (Boolean) regexp?
Instance Method Details
- (Object) __add__(object)
Combine the two objects using the add strategy.
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.
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.
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.
115 |
# File 'lib/origin/extensions/object.rb', line 115 def __deep_copy__; self; end |
- (Array) __intersect__(object)
Combine the two objects using the intersect strategy.
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.
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.
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.
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.
102 103 104 |
# File 'lib/origin/extensions/object.rb', line 102 def __union_from_object__(object) (Array(object) + Array(self)).uniq end |
- (Boolean) regexp?
129 130 131 |
# File 'lib/origin/extensions/object.rb', line 129 def regexp? false end |