From 3e86d878ff81f3db8205922f7d34f4faffdcde31 Mon Sep 17 00:00:00 2001 From: Benjamin Reynolds Date: Wed, 26 Oct 2016 20:38:57 -0500 Subject: [PATCH] Remove `&.` syntax for ruby < 2.3 compatability --- lib/pundit/resource.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/pundit/resource.rb b/lib/pundit/resource.rb index 02a2d3a..dd10111 100644 --- a/lib/pundit/resource.rb +++ b/lib/pundit/resource.rb @@ -16,7 +16,7 @@ def records(options = {}) warn_if_show_defined context = options[:context] - context[:policy_used]&.call + context[:policy_used].try(:call) Pundit.policy_scope!(context[:current_user], _model_class) end @@ -35,13 +35,15 @@ def warn_if_show_defined def can(method) run_callbacks :policy_authorize do - context[:policy_used]&.call + context[:policy_used].try(:call) policy.public_send(method) end end def current_user - context&.[](:current_user) + return unless context + + context[:current_user] end def policy