Don't extend Ruby core

This commit is contained in:
Steve Richert 2012-04-23 13:30:11 -04:00
parent 4c7e836933
commit e48aa4e141
3 changed files with 7 additions and 17 deletions

View file

@ -2,5 +2,4 @@ require 'base64'
require 'cgi'
require 'openssl'
require 'uri'
require 'simple_oauth/core_ext/object'
require 'simple_oauth/header'

View file

@ -1,10 +0,0 @@
major, minor, patch = RUBY_VERSION.split('.')
if major.to_i == 1 && minor.to_i == 8 && patch.to_i <= 6
class Object
def tap
yield self
self
end
end
end

View file

@ -30,17 +30,18 @@ module SimpleOAuth
def initialize(method, url, params, oauth = {})
@method = method.to_s.upcase
@uri = URI.parse(url.to_s).tap do |uri|
uri.scheme = uri.scheme.downcase
uri.normalize!
uri.fragment = nil
end
@uri = URI.parse(url.to_s)
@uri.scheme = @uri.scheme.downcase
@uri.normalize!
@uri.fragment = nil
@params = params
@options = oauth.is_a?(Hash) ? self.class.default_options.merge(oauth) : self.class.parse(oauth)
end
def url
@uri.dup.tap{|u| u.query = nil }.to_s
uri = @uri.dup
uri.query = nil
uri.to_s
end
def to_s