Module: Origin::Extensions::String::ClassMethods

Defined in:
lib/origin/extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#__expr_part__(key, value, negating = false) ⇒ Hash

Get the value as a expression.

Examples:

Get the value as an expression.

String.__expr_part__("field", value)

Since:

  • 2.0.0



103
104
105
106
107
108
109
# File 'lib/origin/extensions/string.rb', line 103

def __expr_part__(key, value, negating = false)
  if negating
    { key => { "$#{value.regexp? ? "not" : "ne"}" => value }}
  else
    { key => value }
  end
end

#evolve(object) ⇒ String

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

Examples:

Evolve the string

String.evolve(1)

Since:

  • 1.0.0



122
123
124
125
126
# File 'lib/origin/extensions/string.rb', line 122

def evolve(object)
  __evolve__(object) do |obj|
    obj.regexp? ? obj : obj.to_s
  end
end