Sha256: 41866e955077a259fb59bf611c2d6db0a59d256a891dab499f16a41bb6dffa9e

Contents?: true

Size: 549 Bytes

Versions: 11

Compression:

Stored size: 549 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Boolean #:nodoc:
      module Conversions #:nodoc:

        BOOLEAN_MAP = {
          true => true, "true" => true, "TRUE" => true, "1" => true, 1 => true, 1.0 => true,
          false => false, "false" => false, "FALSE" => false, "0" => false, 0 => false, 0.0 => false
        }

        def set(value)
          value = BOOLEAN_MAP[value]
          value.nil? ? nil : value
        end
        def get(value)
          value
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
mongoid-1.9.5 lib/mongoid/extensions/boolean/conversions.rb
mongoid-with-auth-1.9.4 lib/mongoid/extensions/boolean/conversions.rb
mongoid-rails2-1.9.4 lib/mongoid/extensions/boolean/conversions.rb
mongoid-rails2-1.9.3 lib/mongoid/extensions/boolean/conversions.rb
mongoid-1.9.2 lib/mongoid/extensions/boolean/conversions.rb
sskirby-mongoid-1.9.1 lib/mongoid/extensions/boolean/conversions.rb
mongoid-2.0.0.beta.7 lib/mongoid/extensions/boolean/conversions.rb
mongoid-1.9.1 lib/mongoid/extensions/boolean/conversions.rb
chhean-mongoid-2.0.1.beta1 lib/mongoid/extensions/boolean/conversions.rb
mongoid-2.0.0.beta.5 lib/mongoid/extensions/boolean/conversions.rb
mongoid-1.9.0 lib/mongoid/extensions/boolean/conversions.rb