Module: Mongoid::Criteria::Queryable::Extensions::String
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Defined in: | lib/mongoid/criteria/queryable/extensions/string.rb |
Overview
Adds query type-casting behavior to String
class.
Instance Method Summary
-
#__evolve_date__ ⇒ Time
Evolve the string into a mongodb friendly date.
-
#__evolve_time__ ⇒ Time
Evolve the string into a mongodb friendly time.
-
#__expr_part__(value, negating = false) ⇒ Hash
Get the string as a specification.
-
#__mongo_expression__ ⇒ String
Get the string as a mongo expression, adding $ to the front.
-
#__sort_option__ ⇒ Hash
Get the string as a sort option.
Instance Method Details
#__evolve_date__ ⇒ Time
Evolve the string into a mongodb friendly date.
#__evolve_time__ ⇒ Time
Evolve the string into a mongodb friendly time.
# File 'lib/mongoid/criteria/queryable/extensions/string.rb', line 29
def __evolve_time__ __mongoize_time__.utc end
#__expr_part__(value, negating = false) ⇒ Hash
Get the string as a specification.
# File 'lib/mongoid/criteria/queryable/extensions/string.rb', line 67
def __expr_part__(value, negating = false) ::String.__expr_part__(self, value, negating) end
#__mongo_expression__ ⇒ String
Get the string as a mongo expression, adding $ to the front.
# File 'lib/mongoid/criteria/queryable/extensions/string.rb', line 39
def __mongo_expression__ start_with?("$") ? self : "$#{self}" end
#__sort_option__ ⇒ Hash
Get the string as a sort option.
# File 'lib/mongoid/criteria/queryable/extensions/string.rb', line 49
def __sort_option__ split(/,/).inject({}) do |hash, spec| hash.tap do |_hash| field, direction = spec.strip.split(/\s/) _hash[field.to_sym] = Mongoid::Criteria::Translator.to_direction(direction) end end end