Permalink
Browse files

Remove String core extensions

  • Loading branch information...
1 parent 0a8591e commit 5a9144c3f5104a7ee13b4c50f32cf71151004023 @sferik committed Nov 21, 2012
Showing with 4 additions and 14 deletions.
  1. +0 −10 lib/twitter/core_ext/string.rb
  2. +4 −4 lib/twitter/factory.rb
View
10 lib/twitter/core_ext/string.rb
@@ -1,10 +0,0 @@
-class String
-
- # Converts a snake_case string to CamelCase
- #
- # @return [String]
- def camelize
- self.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
- end unless method_defined?(:camelize)
-
-end
View
8 lib/twitter/factory.rb
@@ -1,5 +1,3 @@
-require 'twitter/core_ext/string'
-
module Twitter
class Factory
@@ -10,8 +8,10 @@ class Factory
# @return [Twitter::Action::Favorite, Twitter::Action::Follow, Twitter::Action::ListMemberAdded, Twitter::Action::Mention, Twitter::Action::Reply, Twitter::Action::Retweet]
def self.fetch_or_new(method, klass, attrs={})
return unless attrs
- if type = attrs.delete(method.to_sym)
- klass.const_get(type.camelize.to_sym).fetch_or_new(attrs)
+ type = attrs.delete(method.to_sym)
+ if type
+ const_name = type.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
+ klass.const_get(const_name.to_sym).fetch_or_new(attrs)
else
raise ArgumentError, "argument must have :#{method} key"
end

0 comments on commit 5a9144c

Please sign in to comment.