Permalink
Browse files

Updated to mongo 0.18.3. Overwrote Mongo::ObjectID#to_json to be more…

… friendly for most people and aliased ruby driver to original_to_json.
  • Loading branch information...
1 parent f5ca4ec commit eeec9ea9f41404bb7455468c7399fa910cc24b07 @jnunemaker jnunemaker committed Jan 28, 2010
Showing with 9 additions and 4 deletions.
  1. +1 −1 Rakefile
  2. +1 −1 lib/mongo_mapper.rb
  3. +2 −1 lib/mongo_mapper/support.rb
  4. +5 −1 test/unit/test_support.rb
View
2 Rakefile
@@ -12,7 +12,7 @@ Jeweler::Tasks.new do |gem|
gem.authors = ["John Nunemaker"]
gem.add_dependency('activesupport', '>= 2.3')
- gem.add_dependency('mongo', '0.18.2')
+ gem.add_dependency('mongo', '0.18.3')
gem.add_dependency('jnunemaker-validatable', '1.8.1')
gem.add_development_dependency('jnunemaker-matchy', '0.4.0')
View
2 lib/mongo_mapper.rb
@@ -6,7 +6,7 @@
# if there is a better way to do this, please enlighten me!
if self.class.const_defined?(:Gem)
gem 'activesupport', '>= 2.3'
- gem 'mongo', '0.18.2'
+ gem 'mongo', '0.18.3'
gem 'jnunemaker-validatable', '1.8.1'
end
View
3 lib/mongo_mapper/support.rb
@@ -205,8 +205,9 @@ def self.from_mongo(value)
end
end
-# TODO: Remove when patch accepted into driver
class Mongo::ObjectID
+ alias_method :original_to_json, :to_json
+
def to_json(options = nil)
%Q("#{to_s}")
end
View
6 test/unit/test_support.rb
@@ -345,6 +345,10 @@ class SupportTest < Test::Unit::TestCase
id = Mongo::ObjectID.new
id.to_json.should == %Q("#{id}")
end
+
+ should "support ruby driver syntax also" do
+ id = Mongo::ObjectID.new
+ id.original_to_json.should == %Q({"$oid": "#{id}"})
+ end
end
-
end

0 comments on commit eeec9ea

Please sign in to comment.