Sha256: ce2aeaf80f4be53a825334301cc6c24dc996da3f1727604f77ca4ccbb8e34ce8
Contents?: true
Size: 888 Bytes
Versions: 61
Compression:
Stored size: 888 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Extensions module Boolean Mapping = { true => true, 'true' => true, 'TRUE' => true, 'True' => true, 't' => true, 'T' => true, '1' => true, 1 => true, 1.0 => true, false => false, 'false' => false, 'FALSE' => false, 'False' => false, 'f' => false, 'F' => false, '0' => false, 0 => false, 0.0 => false, nil => nil } def to_mongo(value) if value.is_a?(Boolean) value else Mapping[value] end end def from_mongo(value) value.nil? ? nil : !!value end end end end class Boolean extend MongoMapper::Extensions::Boolean end
Version data entries
61 entries across 61 versions & 7 rubygems