carlosparamio / mongo_odm

Flexible persistence module for any Ruby class to MongoDB
http://github.com/carlosparamio/mongo_odm
MIT License
41 stars 8 forks source link

"0" to False conversion for Boolean fields #9

Closed michalkrause closed 13 years ago

michalkrause commented 13 years ago

Hello, I have made small change which enables conversion of "0" (string containing one ASCII zero) to false value for Boolean fields. This makes integration with HTML forms and/or HTTP request params much easier.

carlosparamio commented 13 years ago

Good idea!

However, I will commit a different change that:

1) Included on the same "when" than the regular expresion that evaluates strings with "f" to false

2) Using a comparison with either the literal "0" or a more generic regexp like /^\s*0/, because /^0$/ would only match when the value is exactly "0".

Thanks a lot!

carlosparamio commented 13 years ago

Sorry, the github editor interprets the "initial of string" character of the regular expression as the beginning of an upper text :)

michalkrause commented 13 years ago

Thanks :) BTW, Mongo_ODM is great - it is exactly what I was looking for :)

carlosparamio commented 13 years ago

Thanks to you!

I have big plans for MongoODM. Stay tuned! :)