Skip to content

Commit 6796b39

Browse files
committed
goodbye try
1 parent f60a0dd commit 6796b39

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

lib/rack/oauth2/access_token/legacy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def initialize(attributes = {})
77
self.expires_in = (
88
self.expires_in ||
99
attributes[:expires]
10-
).try(:to_i)
10+
)&.to_i
1111
end
1212

1313
def authenticate(request)

lib/rack/oauth2/client.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ def access_token!(*args)
7474
params.merge! @grant.as_json
7575
params.merge! options
7676
handle_response do
77-
http_client.post(absolute_uri_for(token_endpoint), Util.compact_hash(params), headers)
77+
http_client.post(
78+
absolute_uri_for(token_endpoint),
79+
Util.compact_hash(params),
80+
headers
81+
)
7882
end
7983
end
8084

@@ -130,7 +134,7 @@ def authenticated_context_from(*args)
130134
# Using Array#extract_options! for backward compatibility.
131135
# Until v1.0.5, the first argument was 'client_auth_method' in scalar.
132136
options = args.extract_options!
133-
client_auth_method = args.first || options.delete(:client_auth_method).try(:to_sym) || :basic
137+
client_auth_method = args.first || options.delete(:client_auth_method)&.to_sym || :basic
134138

135139
case client_auth_method
136140
when :basic
@@ -206,7 +210,7 @@ def handle_revocation_response
206210

207211
def handle_success_response(response)
208212
token_hash = JSON.parse(response.body).with_indifferent_access
209-
case (@forced_token_type || token_hash[:token_type]).try(:downcase)
213+
case (@forced_token_type || token_hash[:token_type])&.downcase
210214
when 'bearer'
211215
AccessToken::Bearer.new(token_hash)
212216
when nil

lib/rack/oauth2/server/extension/pkce.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(env)
2727

2828
def verify_code_verifier!(code_challenge, code_challenge_method = :S256)
2929
if code_verifier.present? || code_challenge.present?
30-
case code_challenge_method.try(:to_sym)
30+
case code_challenge_method&.to_sym
3131
when :S256
3232
code_challenge == Util.urlsafe_base64_encode(
3333
OpenSSL::Digest::SHA256.digest(code_verifier.to_s)

spec/helpers/webmock_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def mock_response(method, endpoint, response_file, options = {})
1313

1414
def request_for(method, options = {})
1515
request = {}
16-
params = options.try(:[], :params) || {}
16+
params = options&.[](:params) || {}
1717
case method
1818
when :post, :put, :delete
1919
request[:body] = params

0 commit comments

Comments
 (0)