Class: Clusters::AgentTokens::RevokeService
- Inherits:
-
Object
- Object
- Clusters::AgentTokens::RevokeService
- Defined in:
- app/services/clusters/agent_tokens/revoke_service.rb
Instance Attribute Summary collapse
-
#current_project ⇒ Object
readonly
Returns the value of attribute current_project.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(token:, current_user:) ⇒ RevokeService
constructor
A new instance of RevokeService.
Constructor Details
#initialize(token:, current_user:) ⇒ RevokeService
Returns a new instance of RevokeService.
8 9 10 11 |
# File 'app/services/clusters/agent_tokens/revoke_service.rb', line 8 def initialize(token:, current_user:) @token = token @current_user = current_user end |
Instance Attribute Details
#current_project ⇒ Object (readonly)
Returns the value of attribute current_project.
6 7 8 |
# File 'app/services/clusters/agent_tokens/revoke_service.rb', line 6 def current_project @current_project end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/services/clusters/agent_tokens/revoke_service.rb', line 6 def current_user @current_user end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'app/services/clusters/agent_tokens/revoke_service.rb', line 6 def token @token end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/clusters/agent_tokens/revoke_service.rb', line 13 def execute return unless current_user.can?(:create_cluster, token.agent.project) if token.revoke! log_activity_event(token) ServiceResponse.success else ServiceResponse.error(message: token.errors.) end end |