Module: Mongoid::Extensions::Symbol::Inflections
- Included in:
- Symbol
- Defined in:
- lib/mongoid/extensions/symbol/inflections.rb
Overview
This module contains convenience methods for symbol inflection and conversion.
Constant Summary collapse
- REVERSALS =
{ :asc => :desc, :ascending => :descending, :desc => :asc, :descending => :ascending }
Instance Method Summary collapse
-
#invert ⇒ String
Get the inverted sorting option.
-
#oper ⇒ Criterion::Complex
Define all the necessary methods on symbol to support Mongoid’s complex criterion.
Instance Method Details
#invert ⇒ String
Get the inverted sorting option.
23 24 25 |
# File 'lib/mongoid/extensions/symbol/inflections.rb', line 23 def invert REVERSALS[self] end |
#oper ⇒ Criterion::Complex
Define all the necessary methods on symbol to support Mongoid’s complex criterion.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mongoid/extensions/symbol/inflections.rb', line 36 [ "all", "asc", "ascending", "desc", "descending", "exists", "gt", "gte", "in", "lt", "lte", "mod", "ne", "near", "not", "nin", "size", "within", ["matches","elemMatch"] ].each do |oper| m, oper = oper oper = m unless oper class_eval <<-OPERATORS def #{m} Criterion::Complex.new(:key => self, :operator => "#{oper}") end OPERATORS end |