Sha256: ce4f6b86bd50a5015129e0ec78850421c2aaba1a655447b087af14957f5c637b
Contents?: true
Size: 922 Bytes
Versions: 10
Compression:
Stored size: 922 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; end unless defined?(Boolean) Boolean.extend MongoMapper::Extensions::Boolean
Version data entries
10 entries across 10 versions & 3 rubygems