Sha256: aee52333a08782d1fd19f03174516bbc9b736bec7644d5fcf6a44a44e8254048
Contents?: true
Size: 969 Bytes
Versions: 8
Compression:
Stored size: 969 Bytes
Contents
# frozen_string_literal: true module Mongoid class Criteria module Queryable module Extensions # This module contains extensions for boolean selection. module Boolean module ClassMethods # 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. # # @example Evolve the value to a boolean. # Boolean.evolve(true) # # @param [ Object ] object The object to evolve. # # @return [ true, false ] The boolean value. 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 end end end end end end Mongoid::Boolean.__send__(:extend, Mongoid::Criteria::Queryable::Extensions::Boolean::ClassMethods)
Version data entries
8 entries across 8 versions & 1 rubygems