Skip to content

Commit

Permalink
Remove dependency on activesupport for singleton_class
Browse files Browse the repository at this point in the history
This change can be reverted when the required Ruby version >= 1.9.

Closes #264.
  • Loading branch information
sferik committed Jun 1, 2012
1 parent 538cd2f commit 2ed9db2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions lib/twitter/core_ext/kernel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Kernel

# Returns the object's singleton class.
def singleton_class
class << self
self
end
end unless respond_to?(:singleton_class) # exists in 1.9.2

# class_eval on an object acts like singleton_class.class_eval.
def class_eval(*args, &block)
singleton_class.class_eval(*args, &block)
end

end
4 changes: 2 additions & 2 deletions lib/twitter/cursor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'active_support/core_ext/kernel/singleton_class'
require 'twitter/base'
require 'twitter/core_ext/kernel'

module Twitter
class Cursor < Twitter::Base
Expand All @@ -23,7 +23,7 @@ def initialize(attrs, method, klass=nil)
item
end
end
singleton_class.class_eval do
class_eval do
alias_method method.to_sym, :collection
end
end
Expand Down
1 change: 0 additions & 1 deletion twitter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require File.expand_path('../lib/twitter/version', __FILE__)

Gem::Specification.new do |gem|
gem.add_dependency 'activesupport', ['>= 2.3.9', '< 4']
gem.add_dependency 'faraday', '~> 0.8'
gem.add_dependency 'multi_json', '~> 1.3'
gem.add_dependency 'simple_oauth', '~> 0.1.6'
Expand Down

0 comments on commit 2ed9db2

Please sign in to comment.