Skip to content
This repository
Browse code

Remove String core extensions

  • Loading branch information...
commit 5a9144c3f5104a7ee13b4c50f32cf71151004023 1 parent 0a8591e
Erik Michaels-Ober authored

Showing 2 changed files with 4 additions and 14 deletions. Show diff stats Hide diff stats

  1. +0 10 lib/twitter/core_ext/string.rb
  2. +4 4 lib/twitter/factory.rb
10 lib/twitter/core_ext/string.rb
... ... @@ -1,10 +0,0 @@
1   -class String
2   -
3   - # Converts a snake_case string to CamelCase
4   - #
5   - # @return [String]
6   - def camelize
7   - self.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
8   - end unless method_defined?(:camelize)
9   -
10   -end
8 lib/twitter/factory.rb
... ... @@ -1,5 +1,3 @@
1   -require 'twitter/core_ext/string'
2   -
3 1 module Twitter
4 2 class Factory
5 3
@@ -10,8 +8,10 @@ class Factory
10 8 # @return [Twitter::Action::Favorite, Twitter::Action::Follow, Twitter::Action::ListMemberAdded, Twitter::Action::Mention, Twitter::Action::Reply, Twitter::Action::Retweet]
11 9 def self.fetch_or_new(method, klass, attrs={})
12 10 return unless attrs
13   - if type = attrs.delete(method.to_sym)
14   - klass.const_get(type.camelize.to_sym).fetch_or_new(attrs)
  11 + type = attrs.delete(method.to_sym)
  12 + if type
  13 + const_name = type.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
  14 + klass.const_get(const_name.to_sym).fetch_or_new(attrs)
15 15 else
16 16 raise ArgumentError, "argument must have :#{method} key"
17 17 end

0 comments on commit 5a9144c

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