Sha256: c16322af2a9e63b7270ddd7c31dc35178122258af65789a5af19374070e96b0c

Contents?: true

Size: 1021 Bytes

Versions: 21

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

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.
            #
            # @since 1.0.0
            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

::Boolean.__send__(:extend, Mongoid::Criteria::Queryable::Extensions::Boolean::ClassMethods)

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
mongoid-7.1.11 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.6 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.5 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.10 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.9 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.4 lib/mongoid/criteria/queryable/extensions/boolean.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.3 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.8 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.2 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.1 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.7 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.0 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.6 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.5 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.2.0.rc1 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.4 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.2 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.1 lib/mongoid/criteria/queryable/extensions/boolean.rb
mongoid-7.1.0 lib/mongoid/criteria/queryable/extensions/boolean.rb