Skip to content

Instantly share code, notes, and snippets.

@jnunemaker
Created May 7, 2010 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnunemaker/393404 to your computer and use it in GitHub Desktop.
Save jnunemaker/393404 to your computer and use it in GitHub Desktop.
MongoMapper patching
# 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