-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from xero-gateway/use-module-prepend
Swaps out alias_method_chain for Module#prepend
- Loading branch information
Showing
2 changed files
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |