Class: BlockKit::Elements::BaseButton

Inherits:
Base
  • Object
show all
Defined in:
lib/block_kit/elements/base_button.rb

Direct Known Subclasses

Button, WorkflowButton

Constant Summary collapse

MAX_TEXT_LENGTH =
75
MAX_ACCESSIBILITY_LABEL_LENGTH =
75
VALID_STYLES =
[
  PRIMARY = "primary",
  DANGER = "danger"
].freeze

Constants inherited from Base

BlockKit::Elements::Base::MAX_ACTION_ID_LENGTH

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, fix, #fix_validation_errors, #fix_validation_errors!, fixes, #inspect, inspect, #pretty_print, #to_json

Constructor Details

#initialize(attributes = {}) ⇒ BaseButton

Returns a new instance of BaseButton.

Raises:

  • (NotImplementedError)


34
35
36
37
38
# File 'lib/block_kit/elements/base_button.rb', line 34

def initialize(attributes = {})
  raise NotImplementedError, "#{self.class} is an abstract class and can't be instantiated." if instance_of?(BaseButton)

  super
end

Class Method Details

.inherited(subclass) ⇒ Object



30
31
32
# File 'lib/block_kit/elements/base_button.rb', line 30

def self.inherited(subclass)
  subclass.attribute_fixers = attribute_fixers.deep_dup
end

Instance Method Details

#as_jsonObject



40
41
42
43
44
45
46
# File 'lib/block_kit/elements/base_button.rb', line 40

def as_json(*)
  super.merge(
    text: text&.as_json,
    style: style,
    accessibility_label: accessibility_label
  ).compact
end