class Slack::BlockKit::Element::ButtonElement
Attributes
style[R]
text[R]
value[RW]
Public Class Methods
populate(hash, object)
click to toggle source
Calls superclass method
Slack::BlockKit::Element::populate
# 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
Public Instance Methods
style=(obj)
click to toggle source
# File lib/slack/block_kit/element/button_element.rb, line 30 def style=(obj) unless %i( default primary danger ).include?(obj.to_sym) raise ArgumentError, 'style may only be default, primary, or danger' end @style = obj.to_sym end
text=(obj)
click to toggle source
# File lib/slack/block_kit/element/button_element.rb, line 24 def text=(obj) raise TypeError, 'text must be a Text Object' unless obj.is_a?(CompositionObjects::Text) @text = obj end
to_h()
click to toggle source
Calls superclass method
Slack::BlockKit::Element#to_h
# 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?()
click to toggle source
# File lib/slack/block_kit/element/button_element.rb, line 20 def valid? !@text.empty? end