Skip to content
This repository
Browse code

Remove dependency on activesupport for singleton_class

This change can be reverted when the required Ruby version >= 1.9.

Closes #264.
  • Loading branch information...
commit 2ed9db21c87d1218b15373e42a36ad536b07dcbb 1 parent 538cd2f
Erik Michaels-Ober authored May 31, 2012
15  lib/twitter/core_ext/kernel.rb
... ...
@@ -0,0 +1,15 @@
  1
+module Kernel
  2
+
  3
+  # Returns the object's singleton class.
  4
+  def singleton_class
  5
+    class << self
  6
+      self
  7
+    end
  8
+  end unless respond_to?(:singleton_class) # exists in 1.9.2
  9
+
  10
+  # class_eval on an object acts like singleton_class.class_eval.
  11
+  def class_eval(*args, &block)
  12
+    singleton_class.class_eval(*args, &block)
  13
+  end
  14
+
  15
+end
4  lib/twitter/cursor.rb
... ...
@@ -1,5 +1,5 @@
1  
-require 'active_support/core_ext/kernel/singleton_class'
2 1
 require 'twitter/base'
  2
+require 'twitter/core_ext/kernel'
3 3
 
4 4
 module Twitter
5 5
   class Cursor < Twitter::Base
@@ -23,7 +23,7 @@ def initialize(attrs, method, klass=nil)
23 23
           item
24 24
         end
25 25
       end
26  
-      singleton_class.class_eval do
  26
+      class_eval do
27 27
         alias_method method.to_sym, :collection
28 28
       end
29 29
     end
1  twitter.gemspec
@@ -2,7 +2,6 @@
2 2
 require File.expand_path('../lib/twitter/version', __FILE__)
3 3
 
4 4
 Gem::Specification.new do |gem|
5  
-  gem.add_dependency 'activesupport', ['>= 2.3.9', '< 4']
6 5
   gem.add_dependency 'faraday', '~> 0.8'
7 6
   gem.add_dependency 'multi_json', '~> 1.3'
8 7
   gem.add_dependency 'simple_oauth', '~> 0.1.6'

0 notes on commit 2ed9db2

Please sign in to comment.
Something went wrong with that request. Please try again.