Module: Sand::Helpers
- Included in:
- RequestMethods
- Defined in:
- lib/sand/helpers.rb
Instance Method Summary collapse
- #authorize(user, record, query) ⇒ Object
- #policy_scope(user, record) ⇒ Object
- #skip_sand_authorization ⇒ Object
- #skip_sand_scoping ⇒ Object
Instance Method Details
#authorize(user, record, query) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/sand/helpers.rb', line 9 def (user, record, query) policy = Sand.policy!(user, record) unless policy.public_send(query) raise Sand::NotAuthorizedError.new(policy: policy, query: query, record: record) # rubocop:disable Metrics/LineLength, Style/RaiseArgs end end |
#policy_scope(user, record) ⇒ Object
3 4 5 6 7 |
# File 'lib/sand/helpers.rb', line 3 def policy_scope(user, record) scoped! scope = PolicyFinder.new(record).scope! scope.new(user, record).resolve if scope end |
#skip_sand_authorization ⇒ Object
17 18 19 |
# File 'lib/sand/helpers.rb', line 17 def end |
#skip_sand_scoping ⇒ Object
21 22 23 |
# File 'lib/sand/helpers.rb', line 21 def skip_sand_scoping scoped! end |