Module: Origin::Extensions::Array
- Defined in:
- lib/origin/extensions/array.rb
Overview
The array module adds custom behaviour for Origin onto the Array class.
Instance Method Summary (collapse)
-
- (Object) __add__(object)
Combine the two objects using the add strategy.
-
- (Array) __array__
Return the object as an array.
-
- (Array) __deep_copy__
Makes a deep copy of the array, deep copying every element inside the array.
-
- (Array<Time>) __evolve_date__
Evolve the array into an array of mongo friendly dates.
-
- (Array<Time>) __evolve_time__
Evolve the array to an array of times.
-
- (Object) __intersect__(object)
Combine the two objects using an intersection strategy.
-
- (Hash) __sort_option__
Gets the array as options in the proper format to pass as MongoDB sort criteria.
-
- (Hash) __sort_pair__
Get the array as a sort pair.
Instance Method Details
- (Object) __add__(object)
Combine the two objects using the add strategy.
18 19 20 |
# File 'lib/origin/extensions/array.rb', line 18 def __add__(object) object.__add_from_array__(self) end |
- (Array) __array__
Return the object as an array.
30 |
# File 'lib/origin/extensions/array.rb', line 30 def __array__; self; end |
- (Array) __deep_copy__
Makes a deep copy of the array, deep copying every element inside the array.
41 42 43 |
# File 'lib/origin/extensions/array.rb', line 41 def __deep_copy__ map { |value| value.__deep_copy__ } end |
- (Array<Time>) __evolve_date__
Evolve the array into an array of mongo friendly dates. (Times at midnight).
54 55 56 |
# File 'lib/origin/extensions/array.rb', line 54 def __evolve_date__ map { |value| value.__evolve_date__ } end |
- (Array<Time>) __evolve_time__
Evolve the array to an array of times.
66 67 68 |
# File 'lib/origin/extensions/array.rb', line 66 def __evolve_time__ map { |value| value.__evolve_time__ } end |
- (Object) __intersect__(object)
Combine the two objects using an intersection strategy.
80 81 82 |
# File 'lib/origin/extensions/array.rb', line 80 def __intersect__(object) object.__intersect_from_array__(self) end |
- (Hash) __sort_option__
Gets the array as options in the proper format to pass as MongoDB sort criteria.
93 94 95 96 97 98 |
# File 'lib/origin/extensions/array.rb', line 93 def __sort_option__ multi.inject({}) do |, criteria| .merge!(criteria.__sort_pair__) end end |
- (Hash) __sort_pair__
Get the array as a sort pair.
108 109 110 |
# File 'lib/origin/extensions/array.rb', line 108 def __sort_pair__ { first => last.to_direction } end |