Permalink
Browse files

Use Ruby 1.9.x's "BasicObject" in place of BlankSlate when available

With the 3.0.2 release of Builder, requiring thinking_sphinx leads to
the following warning message:

  gems/builder-3.0.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems

Where possible, then, it makes sense to use BasicObject instead to avoid the warning message
getting barfed out every time rake is invoked.
  • Loading branch information...
1 parent e83018c commit 98de2546a07f5e97aeef0ca1249cf25e7286fc6c @purcell purcell committed Sep 8, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/thinking_sphinx/index/builder.rb
@@ -1,4 +1,4 @@
-require 'blankslate'
+require 'blankslate' unless defined?(BasicObject)
module ThinkingSphinx
class Index
@@ -14,7 +14,7 @@ class Index
# set_property allows you to set some settings on a per-index basis. Check
# out each method's documentation for better ideas of usage.
#
- class Builder < BlankSlate
+ class Builder < (defined?(BasicObject) ? BasicObject : BlankSlate)
def self.generate(model, name = nil, &block)
index = ThinkingSphinx::Index.new(model)
index.name = name unless name.nil?

6 comments on commit 98de254

BasicObject does not include Kernel (for methods like puts) and BasicObject is outside of the namespace of the standard library so common classes will not be found without a using a full class path.

BasicObject != BlankSlate

so on line 19, ThinkingSphinx needs to be in ::ThinkingSphinx
and all other references thereto.

this causes an error

NameError: uninitialized constant ThinkingSphinx::Index::Builder::ThinkingSphinx

Owner
pat replied Sep 16, 2012

Good catch, I'll fix that up tonight.

Owner
pat replied Sep 17, 2012

Give the latest a try, should be all fine now.

The error I was seeing is gone now. Thanks Pat!

Sorry about that, guys -- my bad.

Owner
pat replied Sep 17, 2012

No worries, an easy fix - this is why I don't rush gem releases out, I've done stupid things like this before too.

Please sign in to comment.