Skip to content

Instantly share code, notes, and snippets.

@german
Created December 7, 2010 09:00
Show Gist options
  • Save german/731600 to your computer and use it in GitHub Desktop.
Save german/731600 to your computer and use it in GitHub Desktop.
mongo_mapper's gem fix
From 9bed12e78880a4ddce90ca4a846090773bc8538d Mon Sep 17 00:00:00 2001
From: Dmitrii Samoilov <germaninthetown@gmail.com>
Date: Tue, 20 Jul 2010 11:10:51 +0300
Subject: [PATCH] fix for the bug in plugins.rb (const_defined?(:ClassMethods) for whatever reason doesn't work for rails3b4 and ruby1.9.2-rc2)
---
lib/mongo_mapper/plugins.rb | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/mongo_mapper/plugins.rb b/lib/mongo_mapper/plugins.rb
index eba99b6..fc39187 100644
--- a/lib/mongo_mapper/plugins.rb
+++ b/lib/mongo_mapper/plugins.rb
@@ -6,7 +6,9 @@ module MongoMapper
end
def plugin(mod)
- extend mod::ClassMethods if mod.const_defined?(:ClassMethods)
+ # for whatever reason mod.const_defined?(:ClassMethods) doesn't work in ruby192rc2+rails3b4 hence this workaround
+ extend mod::ClassMethods if mod.constants.include?(:ClassMethods)
+
include mod::InstanceMethods if mod.const_defined?(:InstanceMethods)
mod.configure(self) if mod.respond_to?(:configure)
plugins << mod
--
1.5.6.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment