Module: Tiun::Policy
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/tiun/policy.rb
Defined Under Namespace
Classes: NotAuthorizedError, Scope
Instance Method Summary
collapse
Instance Method Details
#match?(allowing_permissions) ⇒ Boolean
18
19
20
|
# File 'lib/tiun/policy.rb', line 18
def match? allowing_permissions
user && (user.permissions & allowing_permissions).any?
end
|
22
23
24
|
# File 'lib/tiun/policy.rb', line 22
def scope
defined?(Pundit) && Pundit.policy_scope!(user, record.class) || ActiveRecord::Base
end
|
#show? ⇒ Boolean
14
15
16
|
# File 'lib/tiun/policy.rb', line 14
def show?
scope.where(id: record.id).exists?
end
|
#valid? ⇒ Boolean
10
11
12
|
# File 'lib/tiun/policy.rb', line 10
def valid?
true
end
|