Class: Mongoid::Boolean
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: | Object |
| Defined in: | lib/mongoid/extensions/boolean.rb |
Overview
Adds type-casting behavior to Boolean class.
Class Method Summary
-
.demongoize(object)
Alias for .mongoize.
-
.mongoize(object) ⇒ true | false | nil
(also: .demongoize)
Turn the object from the ruby type we deal with to a Mongo friendly type.
Criteria::Queryable::Extensions::Boolean::ClassMethods - Extended
| evolve | Evolve the value into a boolean value stored in MongoDB. |
Class Method Details
.demongoize(object)
Alias for .mongoize.
# File 'lib/mongoid/extensions/boolean.rb', line 23
alias demongoize mongoize
.mongoize(object) ⇒ true | false | nil
Also known as: .demongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
# File 'lib/mongoid/extensions/boolean.rb', line 14
def mongoize(object) return if object.nil? if object.to_s&.match?(/\A(true|t|yes|y|on|1|1.0)\z/i) true elsif object.to_s&.match?(/\A(false|f|no|n|off|0|0.0)\z/i) false end end