Skip to content

Instantly share code, notes, and snippets.

@timuruski
Created July 22, 2011 17:39
Show Gist options
  • Select an option

  • Save timuruski/1099935 to your computer and use it in GitHub Desktop.

Select an option

Save timuruski/1099935 to your computer and use it in GitHub Desktop.
require 'mongo_mapper'
MongoMapper.database = 'tmp'
class BoolTest
include MongoMapper::Document
key :value, Boolean, :default => false
end
def test(value)
bool_test = BoolTest.new(:value => value)
puts "#{value.inspect} => #{bool_test.value}, #{bool_test.value?}"
end
puts "Boolean mapping:"
test(nil)
test(true)
test(false)
test('trUe')
test('falSe')
test(0)
test(1)
test(0.000000000000000000001)
test('garbage')
test(:garbage)
test([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment