Module: Mongoid::Extensions::Regexp::ClassMethods
- Defined in:
- build/mongoid-8.1/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.
18 19 20 21 22 23 24 25 26 27 |
# File 'build/mongoid-8.1/lib/mongoid/extensions/regexp.rb', line 18 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 |