Skip to content
This repository
Browse code

Remove dependency on activesupport for each_with_object compatibility…

… in Ruby 1.8

Use Enumerable#inject instead. This change can be reverted when the
required Ruby version >= 1.9.

Progress toward #264.
  • Loading branch information...
commit 6052252a07baf7aefe0f100bba0abd2cbb7139bb 1 parent 9019137
Erik Michaels-Ober authored May 31, 2012
4  lib/twitter/configuration.rb
... ...
@@ -1,4 +1,3 @@
1  
-require 'active_support/core_ext/enumerable'
2 1
 require 'twitter/base'
3 2
 require 'twitter/size'
4 3
 
@@ -11,8 +10,9 @@ class Configuration < Twitter::Base
11 10
     #
12 11
     # @return [Array<Twitter::Size>]
13 12
     def photo_sizes
14  
-      @photo_sizes ||= Array(@attrs['photo_sizes']).each_with_object({}) do |(key, value), object|
  13
+      @photo_sizes ||= Array(@attrs['photo_sizes']).inject({}) do |object, (key, value)|
15 14
         object[key] = Twitter::Size.new(value)
  15
+        object
16 16
       end
17 17
     end
18 18
 
4  lib/twitter/photo.rb
... ...
@@ -1,4 +1,3 @@
1  
-require 'active_support/core_ext/enumerable'
2 1
 require 'twitter/base'
3 2
 require 'twitter/size'
4 3
 
@@ -15,8 +14,9 @@ def ==(other)
15 14
 
16 15
     # @return [Array<Twitter::Size>]
17 16
     def sizes
18  
-      @sizes ||= Array(@attrs['sizes']).each_with_object({}) do |(key, value), object|
  17
+      @sizes ||= Array(@attrs['sizes']).inject({}) do |object, (key, value)|
19 18
         object[key] = Twitter::Size.new(value)
  19
+        object
20 20
       end
21 21
     end
22 22
 

0 notes on commit 6052252

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