Skip to content

Commit

Permalink
Merge pull request #88 from xero-gateway/use-module-prepend
Browse files Browse the repository at this point in the history
Swaps out alias_method_chain for Module#prepend
  • Loading branch information
armstrjare authored Sep 13, 2016
2 parents ddb955c + 294a05e commit b46ef54
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: ruby
rvm:
- "1.9.3"
- "2.2.4"
- "2.3.0"
- "2.3.1"
before_install:
- gem update --system 2.2.2
- gem --version
34 changes: 25 additions & 9 deletions lib/oauth/oauth_consumer.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
module OAuth
class Consumer

def http_with_ssl_client_certificates(*args)
@http ||= http_without_ssl_client_certificates(*args).tap do |http|
http.cert = options[:ssl_client_cert]
http.key = options[:ssl_client_key]

if RUBY_VERSION >= "2.0.0"

# we got Module#prepend, let's use it
module ClientCertificateExtensions
def http
super.tap do |http|
http.cert = options[:ssl_client_cert]
http.key = options[:ssl_client_key]
end
end
end

prepend ClientCertificateExtensions

else
def http_with_ssl_client_certificates(*args)
@http ||= http_without_ssl_client_certificates(*args).tap do |http|
http.cert = options[:ssl_client_cert]
http.key = options[:ssl_client_key]
end
end

alias_method_chain :http, :ssl_client_certificates
end

alias_method_chain :http, :ssl_client_certificates


end
end
end

0 comments on commit b46ef54

Please sign in to comment.