Class: SlackBot::View
- Inherits:
-
Object
- Object
- SlackBot::View
- Includes:
- Concerns::PagerKlass
- Defined in:
- lib/slack_bot/view.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(current_user:, params:, args: nil, context: nil, config: nil) ⇒ View
constructor
A new instance of View.
- #method_missing(method_name, *args, &block) ⇒ Object
- #text_modal ⇒ Object
Methods included from Concerns::PagerKlass
Constructor Details
#initialize(current_user:, params:, args: nil, context: nil, config: nil) ⇒ View
Returns a new instance of View.
10 11 12 13 14 15 16 17 |
# File 'lib/slack_bot/view.rb', line 10 def initialize(current_user:, params:, args: nil, context: nil, config: nil) @current_user = current_user @params = params @config = config || SlackBot::Config.current_instance @args = args @context = context.with_indifferent_access if context.is_a?(Hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/slack_bot/view.rb', line 19 def method_missing(method_name, *args, &block) return @context[method_name.to_sym] if @context.is_a?(Hash) && @context.key?(method_name.to_sym) super end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/slack_bot/view.rb', line 9 def args @args end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/slack_bot/view.rb', line 9 def config @config end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/slack_bot/view.rb', line 9 def context @context end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
9 10 11 |
# File 'lib/slack_bot/view.rb', line 9 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/slack_bot/view.rb', line 9 def params @params end |
Instance Method Details
#text_modal ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/slack_bot/view.rb', line 25 def text_modal { title: { type: "plain_text", text: context[:title] }, blocks: [ {type: "section", text: {type: "mrkdwn", text: context[:text]}} ] } end |