Module: Walruz::Manager::AuthorizationQuery
Instance Method Summary collapse
- #authorize(actor, action, subject) ⇒ Object
- #authorize!(actor, action, subject) ⇒ Object
- #can?(actor, action, subject) ⇒ Boolean
- #satisfies(actor, policy_label, subject) ⇒ Object
- #satisfies!(actor, policy_label, subject) ⇒ Object
- #satisfies?(actor, policy_label, subject) ⇒ Boolean
Instance Method Details
#authorize(actor, action, subject) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/walruz/manager.rb', line 26 def (actor, action, subject) result = Walruz::Manager.(actor, action, subject) result[0] ? result[1] : nil end |
#authorize!(actor, action, subject) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/walruz/manager.rb', line 15 def (actor, action, subject) result = Walruz::Manager.(actor, action, subject) if result[0] result[1] else response_params = result[1] = response_params[:error_message] || "You are not authorized to access this content" raise NotAuthorized.new(actor, subject, action, ) end end |
#can?(actor, action, subject) ⇒ Boolean
11 12 13 |
# File 'lib/walruz/manager.rb', line 11 def can?(actor, action, subject) Walruz::Manager.(actor, action, subject)[0] end |
#satisfies(actor, policy_label, subject) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/walruz/manager.rb', line 40 def satisfies(actor, policy_label, subject) result = Walruz::Manager.(actor, policy_label, subject) result[0] ? result[1] : nil end |
#satisfies!(actor, policy_label, subject) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/walruz/manager.rb', line 47 def satisfies!(actor, policy_label, subject) result = Walruz::Manager.(actor, policy_label, subject) if result[0] result[1] else response_params = result[1] = response_params[:error_message] || "You are not authorized to access this content" raise NotAuthorized.new(actor, subject, :access, ) end end |