Class: Slack::BlockKit::CompositionObjects::OptionGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/composition_objects/option_group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptionGroup

Returns a new instance of OptionGroup.



16
17
18
# File 'lib/slack/block_kit/composition_objects/option_group.rb', line 16

def initialize
  @options = TypeRestrictedArray.new(Option)
end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



7
8
9
# File 'lib/slack/block_kit/composition_objects/option_group.rb', line 7

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/slack/block_kit/composition_objects/option_group.rb', line 7

def options
  @options
end

Class Method Details

.[](hash) ⇒ Object



9
10
11
12
13
14
# File 'lib/slack/block_kit/composition_objects/option_group.rb', line 9

def self.[](hash)
  new.tap do |object|
    object.label = hash.fetch(:label)
    hash[:options].each(&object.options.method(:<<))
  end
end

Instance Method Details

#to_hObject



27
28
29
30
# File 'lib/slack/block_kit/composition_objects/option_group.rb', line 27

def to_h
  { label: label.to_h,
    options: options.map(&:to_h) }
end