Module: Mongoid::Criteria::Queryable::Extensions::Boolean::ClassMethods

Defined in:
build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/boolean.rb

Instance Method Summary collapse

Instance Method Details

#evolve(object) ⇒ true, false

Evolve the value into a boolean value stored in MongoDB. Will return true for any of these values: true, t, yes, y, 1, 1.0.

Examples:

Evolve the value to a boolean.

Boolean.evolve(true)

Parameters:

  • object (Object)

    The object to evolve.

Returns:

  • (true, false)

    The boolean value.

Since:

  • 1.0.0



24
25
26
27
28
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/boolean.rb', line 24

def evolve(object)
  __evolve__(object) do |obj|
    obj.to_s =~ (/\A(true|t|yes|y|on|1|1.0)\z/i) ? true : false
  end
end