diff --git a/lib/twitter/core_ext/string.rb b/lib/twitter/core_ext/string.rb deleted file mode 100644 index 1d7a572b0..000000000 --- a/lib/twitter/core_ext/string.rb +++ /dev/null @@ -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 diff --git a/lib/twitter/factory.rb b/lib/twitter/factory.rb index 274ceda22..9bbbc20ce 100644 --- a/lib/twitter/factory.rb +++ b/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