Class: Banacle::InteractiveMessage::Renderer
- Inherits:
-
Object
- Object
- Banacle::InteractiveMessage::Renderer
- Defined in:
- lib/banacle/interactive_message/renderer.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params, command) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(params, command) ⇒ Renderer
Returns a new instance of Renderer.
23 24 25 26 |
# File 'lib/banacle/interactive_message/renderer.rb', line 23 def initialize(params, command) @params = params @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
28 29 30 |
# File 'lib/banacle/interactive_message/renderer.rb', line 28 def command @command end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
28 29 30 |
# File 'lib/banacle/interactive_message/renderer.rb', line 28 def params @params end |
Class Method Details
.render(params, command) ⇒ Object
7 8 9 |
# File 'lib/banacle/interactive_message/renderer.rb', line 7 def self.render(params, command) new(params, command).render end |
.render_error(error) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/banacle/interactive_message/renderer.rb', line 15 def self.render_error(error) Slack::Response.new( response_type: "ephemeral", replace_original: false, text: "An error occurred: #{error}", ).to_json end |
.render_unauthenticated ⇒ Object
11 12 13 |
# File 'lib/banacle/interactive_message/renderer.rb', line 11 def self.render_unauthenticated self.render_error("you are not authorized to perform this action") end |
Instance Method Details
#render ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/banacle/interactive_message/renderer.rb', line 30 def render action = Slack::Action.new(payload[:actions].first) if action.approved? (payload, command) elsif action.rejected? (payload, command) elsif action.cancelled? (payload, command) else # Do nothing end end |