Skip to content

Commit

Permalink
Replace regular expressions with string manipulations
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Apr 23, 2015
1 parent 3cacce5 commit 70d535b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/twitter/factory.rb
Expand Up @@ -10,7 +10,7 @@ class << self
# @return [Twitter::Base]
def new(method, klass, attrs = {})
type = attrs.fetch(method.to_sym)
const_name = type.gsub(/\/(.?)/) { "::#{Regexp.last_match[1].upcase}" }.gsub(/(?:^|_)(.)/) { Regexp.last_match[1].upcase }
const_name = type.split('_').collect(&:capitalize).join
klass.const_get(const_name.to_sym).new(attrs)
end
end
Expand Down

0 comments on commit 70d535b

Please sign in to comment.