Module: Mongoid::Extensions::Regexp::ClassMethods
- Defined in:
- lib/mongoid/extensions/regexp.rb
Instance Method Summary collapse
-
#mongoize(object) ⇒ Regexp | nil
(also: #demongoize)
Turn the object from the ruby type we deal with to a Mongo friendly type.
Instance Method Details
#mongoize(object) ⇒ Regexp | nil Also known as: demongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mongoid/extensions/regexp.rb', line 21 def mongoize(object) return if object.nil? case object when String then ::Regexp.new(object) when ::Regexp then object when BSON::Regexp::Raw then object.compile end rescue RegexpError nil end |