Module: Jwtauth::Policy
- Defined in:
- lib/jwtauth.rb
Overview
require use Pundit (gem <<pundit>>)
Defined Under Namespace
Modules: ClassMethods, LevelsOfAccess, Privileges
Classes: Scope
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record.
395
396
397
|
# File 'lib/jwtauth.rb', line 395
def record
@record
end
|
#user ⇒ Object
Returns the value of attribute user.
395
396
397
|
# File 'lib/jwtauth.rb', line 395
def user
@user
end
|
Instance Method Details
#_entity_class ⇒ Object
434
435
436
|
# File 'lib/jwtauth.rb', line 434
def _entity_class
@record.is_a?(Class) ? @record.name.underscore : @record.class.name.underscore
end
|
#create? ⇒ Boolean
410
411
412
|
# File 'lib/jwtauth.rb', line 410
def create?
record_action?(get_level_of_access(Privileges::CREATE))
end
|
#destroy? ⇒ Boolean
426
427
428
|
# File 'lib/jwtauth.rb', line 426
def destroy?
record_action?(get_level_of_access(Privileges::DELETE))
end
|
#edit? ⇒ Boolean
422
423
424
|
# File 'lib/jwtauth.rb', line 422
def edit?
update?
end
|
#initialize(user, record) ⇒ Object
397
398
399
400
|
# File 'lib/jwtauth.rb', line 397
def initialize(user, record)
@user = user
@record = record
end
|
#new? ⇒ Boolean
414
415
416
|
# File 'lib/jwtauth.rb', line 414
def new?
create?
end
|
#scope ⇒ Object
430
431
432
|
# File 'lib/jwtauth.rb', line 430
def scope
Pundit.policy_scope!(user, record.class)
end
|
#show? ⇒ Boolean
406
407
408
|
# File 'lib/jwtauth.rb', line 406
def show?
record_action?(get_level_of_access(Privileges::READ))
end
|
#update? ⇒ Boolean
418
419
420
|
# File 'lib/jwtauth.rb', line 418
def update?
record_action?(get_level_of_access(Privileges::UPDATE))
end
|