123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Criteria::Queryable::Extensions::Symbol::ClassMethods

Relationships & Source Files
Defined in: lib/mongoid/criteria/queryable/extensions/symbol.rb

Instance Method Summary

Instance Method Details

#add_key(name, strategy, operator, additional = nil, &block)

Adds a method on symbol as a convenience for the MongoDB operator.

Examples:

Add the $in method.

Symbol.add_key(:in, "$in")

Parameters:

  • name (Symbol)

    The name of the method.

  • strategy (Symbol)

    The name of the merge strategy.

  • operator (String)

    The MongoDB operator.

  • additional (String) (defaults to: nil)

    The additional MongoDB operator.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/symbol.rb', line 36

def add_key(name, strategy, operator, additional = nil, &block)
  define_method(name) do
    method = "__#{strategy}__".to_sym
    Key.new(self, method, operator, additional, &block)
  end
end

#evolve(object) ⇒ Symbol

Evolves the symbol into a MongoDB friendly value - in this case a symbol.

Examples:

Evolve the symbol

Symbol.evolve("test")

Parameters:

  • object (Object)

    The object to convert.

Returns:

  • (Symbol)

    The value as a symbol.

[ GitHub ]

  
# File 'lib/mongoid/criteria/queryable/extensions/symbol.rb', line 52

def evolve(object)
  __evolve__(object) do |obj|
    obj.try(:to_sym)
  end
end