Created
May 7, 2010 13:20
-
-
Save jnunemaker/393404 to your computer and use it in GitHub Desktop.
MongoMapper patching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patch until MM 0.7.6 which fixes this: | |
# http://github.com/jnunemaker/mongomapper/commit/a721b66d9bc9ef78a5ce32dd2eb36d24abd4b953 | |
module SetWithTypecasting | |
def self.included(model) | |
model.plugin SetWithTypecasting | |
end | |
module ClassMethods | |
def set(*args) | |
criteria, updates = criteria_and_keys_from_args(args) | |
updates.each do |key, value| | |
updates[key] = keys[key].set(value) if key?(key) | |
end | |
collection.update(criteria, {'$set' => updates}, :multi => true) | |
end | |
end | |
end | |
MongoMapper::Document.append_inclusions(SetWithTypecasting) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment