Class: RailsApiKeys::UI::ApiKeyPolicy
- Inherits:
-
Object
- Object
- RailsApiKeys::UI::ApiKeyPolicy
- Defined in:
- app/policies/rails_api_keys/ui/api_key_policy.rb
Overview
Default Pundit policy: Devise current_user may manage their own keys.
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, record) ⇒ ApiKeyPolicy
constructor
A new instance of ApiKeyPolicy.
Constructor Details
#initialize(user, record) ⇒ ApiKeyPolicy
Returns a new instance of ApiKeyPolicy.
9 10 11 12 |
# File 'app/policies/rails_api_keys/ui/api_key_policy.rb', line 9 def initialize(user, record) @user = user @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
7 8 9 |
# File 'app/policies/rails_api_keys/ui/api_key_policy.rb', line 7 def record @record end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'app/policies/rails_api_keys/ui/api_key_policy.rb', line 7 def user @user end |
Instance Method Details
#create? ⇒ Boolean
18 19 20 |
# File 'app/policies/rails_api_keys/ui/api_key_policy.rb', line 18 def create? user.present? && owner_matches_user? end |
#destroy? ⇒ Boolean
22 23 24 |
# File 'app/policies/rails_api_keys/ui/api_key_policy.rb', line 22 def destroy? user.present? && owner_matches_user? end |
#index? ⇒ Boolean
14 15 16 |
# File 'app/policies/rails_api_keys/ui/api_key_policy.rb', line 14 def index? user.present? end |