Class: SlackWidgets::StaticPicker

Inherits:
Picker
  • Object
show all
Defined in:
lib/slack_widgets/widgets/pickers/static_picker.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, options:, text: nil, selected_index: nil, value: nil) ⇒ StaticPicker

Returns a new instance of StaticPicker.



3
4
5
6
7
8
# File 'lib/slack_widgets/widgets/pickers/static_picker.rb', line 3

def initialize(name:, options:, text: nil, selected_index: nil, value: nil)
  @options = options
  @value = value
  @pre_selection = selected_index ? options[selected_index] : nil
  super(name: name, text: text)
end

Class Method Details

.create(name:, options:, text: nil, selected_index: nil, value: nil) ⇒ Object



17
18
19
# File 'lib/slack_widgets/widgets/pickers/static_picker.rb', line 17

def self.create(name:, options:, text: nil, selected_index: nil, value: nil)
  new(name: name, options: options, text: text, selected_index: selected_index, value: value).render
end

Instance Method Details

#renderObject



10
11
12
13
14
15
# File 'lib/slack_widgets/widgets/pickers/static_picker.rb', line 10

def render
  super.merge('data_source': 'static',
              'options': @options,
              'selected_options': [@pre_selection],
              'value': @value)
end