Class: Slack::BlockKit::Element::ButtonElement

Inherits:
Slack::BlockKit::Element show all
Defined in:
lib/slack/block_kit/element/button_element.rb

Instance Attribute Summary collapse

Attributes inherited from Slack::BlockKit::Element

#action_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Slack::BlockKit::Element

[], #type

Instance Attribute Details

#styleObject

Returns the value of attribute style.



8
9
10
# File 'lib/slack/block_kit/element/button_element.rb', line 8

def style
  @style
end

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/slack/block_kit/element/button_element.rb', line 8

def text
  @text
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/slack/block_kit/element/button_element.rb', line 9

def value
  @value
end

Class Method Details

.populate(hash, object) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/slack/block_kit/element/button_element.rb', line 11

def self.populate(hash, object)
  object.text = hash.fetch(:text)
  object.action_id = hash.fetch(:action_id) if hash[:action_id]
  object.style = hash.fetch(:style) if hash[:style]
  object.value = hash.fetch(:value) if hash[:value]

  super(hash, object)
end

Instance Method Details

#to_hObject



38
39
40
41
42
43
44
# File 'lib/slack/block_kit/element/button_element.rb', line 38

def to_h
  super.merge(
    text: text.to_h,
    style: style,
    value: value
  ).compact
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/slack/block_kit/element/button_element.rb', line 20

def valid?
  !@text.empty?
end