Class: Banacle::SlashCommand::Renderer
- Inherits:
-
Object
- Object
- Banacle::SlashCommand::Renderer
- Defined in:
- lib/banacle/slash_command/renderer.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request, command, config) ⇒ Renderer
constructor
A new instance of Renderer.
- #render_approval_request ⇒ Object
- #user_id ⇒ Object
Constructor Details
#initialize(request, command, config) ⇒ Renderer
Returns a new instance of Renderer.
13 14 15 16 17 |
# File 'lib/banacle/slash_command/renderer.rb', line 13 def initialize(request, command, config) @request = request @command = command @config = config end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
19 20 21 |
# File 'lib/banacle/slash_command/renderer.rb', line 19 def command @command end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
19 20 21 |
# File 'lib/banacle/slash_command/renderer.rb', line 19 def config @config end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
19 20 21 |
# File 'lib/banacle/slash_command/renderer.rb', line 19 def request @request end |
Class Method Details
Instance Method Details
#render_approval_request ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/banacle/slash_command/renderer.rb', line 21 def render_approval_request text = <<-EOS <@#{user_id}> wants to *#{command.action} NACL DENY entry* under the following conditions: ``` #{JSON.pretty_generate(command.to_h)} ``` EOS Slack::Response.new( response_type: "in_channel", text: text, attachments: [ Slack::Attachment.new( text: config.dig(:approval_request, :attachment, :text) || "*Approval Request*", fallback: "TBD", callback_id: "banacle_approval_request", color: "#3AA3E3", attachment_type: "default", actions: [ Slack::Action., Slack::Action., Slack::Action., ] ), ], ).to_json end |
#user_id ⇒ Object
49 50 51 |
# File 'lib/banacle/slash_command/renderer.rb', line 49 def user_id request.user_id end |