Class: Rails::Approvals::SlackResponse
- Inherits:
-
Object
- Object
- Rails::Approvals::SlackResponse
- Defined in:
- app/models/rails/approvals/slack_response.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#responder ⇒ Object
readonly
Returns the value of attribute responder.
Instance Method Summary collapse
-
#initialize(payload) ⇒ SlackResponse
constructor
A new instance of SlackResponse.
- #perform ⇒ Object
Constructor Details
#initialize(payload) ⇒ SlackResponse
Returns a new instance of SlackResponse.
7 8 9 10 |
# File 'app/models/rails/approvals/slack_response.rb', line 7 def initialize(payload) @payload = payload @responder = payload['user']['username'] end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
4 5 6 |
# File 'app/models/rails/approvals/slack_response.rb', line 4 def payload @payload end |
#responder ⇒ Object (readonly)
Returns the value of attribute responder.
5 6 7 |
# File 'app/models/rails/approvals/slack_response.rb', line 5 def responder @responder end |
Instance Method Details
#perform ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/rails/approvals/slack_response.rb', line 12 def perform payload['actions'].all? do |action| request = GlobalID::Locator.locate(action['block_id']) case action['value'] when 'approve' request.update!( responder: responder, state: :approved, ) when 'deny' request.update!( responder: responder, state: :denied, ) end end end |