Module: Wallaby::Authorizable
- Included in:
- ResourcesConcern, ResourcesHelper
- Defined in:
- lib/concerns/wallaby/authorizable.rb
Overview
Authorizer related
Instance Method Summary collapse
-
#authorized?(action, subject) ⇒ true, false
Check if user is allowed to perform action on given subject.
-
#current_authorizer ⇒ ModelAuthorizer
Model authorizer for current modal class.
-
#unauthorized?(action, subject) ⇒ true, false
Check if user is allowed to perform action on given subject.
Instance Method Details
#authorized?(action, subject) ⇒ true, false
Check if user is allowed to perform action on given subject
23 24 25 26 27 28 |
# File 'lib/concerns/wallaby/authorizable.rb', line 23 def (action, subject) return false unless subject klass = subject.is_a?(Class) ? subject : subject.class (klass).(action, subject) end |
#current_authorizer ⇒ ModelAuthorizer
Model authorizer for current modal class.
10 11 12 13 14 15 |
# File 'lib/concerns/wallaby/authorizable.rb', line 10 def @current_authorizer ||= (current_model_class).tap do || Logger.debug %(Current authorizer: #{.try(:class)}), sourcing: false end end |
#unauthorized?(action, subject) ⇒ true, false
Check if user is allowed to perform action on given subject
36 37 38 |
# File 'lib/concerns/wallaby/authorizable.rb', line 36 def (action, subject) !(action, subject) end |