Module: Mongoid::Criteria::Queryable::Extensions::Array
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Defined in: | lib/mongoid/criteria/queryable/extensions/array.rb |
Overview
Adds query type-casting behavior to Array
class.
Instance Method Summary
-
#__add__(object) ⇒ Object
Combine the two objects using the add strategy.
-
#__array__ ⇒ Array
Return the object as an array.
-
#__deep_copy__ ⇒ Array
Makes a deep copy of the array, deep copying every element inside the array.
-
#__evolve_date__ ⇒ Array<Time>
Evolve the array into an array of mongo friendly dates.
-
#__evolve_time__ ⇒ Array<Time>
Evolve the array to an array of times.
-
#__expand_complex__ ⇒ Array
Get the object as expanded.
-
#__intersect__(object) ⇒ Object
Combine the two objects using an intersection strategy.
-
#__sort_option__ ⇒ Hash
Gets the array as options in the proper format to pass as MongoDB sort criteria.
-
#__sort_pair__ ⇒ Hash
Get the array as a sort pair.
-
#multi ⇒ Array
private
Internal use only
Internal use only
Converts the array to a multi-dimensional array.
Instance Method Details
#__add__(object) ⇒ Object
Combine the two objects using the add strategy.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 20
def __add__(object) object.__add_from_array__(self) end
#__array__ ⇒ Array
Return the object as an array.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 30
def __array__; self; end
#__deep_copy__ ⇒ Array
Makes a deep copy of the array, deep copying every element inside the array.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 39
def __deep_copy__ map { |value| value.__deep_copy__ } end
#__evolve_date__ ⇒ Array
<Time>
Evolve the array into an array of mongo friendly dates. (Times at midnight).
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 50
def __evolve_date__ map { |value| value.__evolve_date__ } end
#__evolve_time__ ⇒ Array
<Time>
Evolve the array to an array of times.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 72
def __evolve_time__ map { |value| value.__evolve_time__ } end
#__expand_complex__ ⇒ Array
Get the object as expanded.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 60
def map do |value| value. end end
#__intersect__(object) ⇒ Object
Combine the two objects using an intersection strategy.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 84
def __intersect__(object) object.__intersect_from_array__(self) end
#__sort_option__ ⇒ Hash
Gets the array as options in the proper format to pass as MongoDB sort criteria.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 95
def __sort_option__ multi.inject({}) do |, criteria| .merge!(criteria.__sort_pair__) end end
#__sort_pair__ ⇒ Hash
Get the array as a sort pair.
# File 'lib/mongoid/criteria/queryable/extensions/array.rb', line 108
def __sort_pair__ { first => Mongoid::Criteria::Translator.to_direction(last) } end
#multi ⇒ Array
(private)
Converts the array to a multi-dimensional array.