class Slack::BlockKit::Element

Attributes

action_id[R]

Public Class Methods

[](hash) click to toggle source
# File lib/slack/block_kit/element.rb, line 13
def self.[](hash)
  new.tap { |obj| populate(hash, obj) }
end
populate(hash, object) click to toggle source
# File lib/slack/block_kit/element.rb, line 8
def self.populate(hash, object)
  object.action_id = hash[:action_id] if hash.key?(:action_id)
  raise ArgumentError, "invalid #{name}" unless object.valid?
end

Public Instance Methods

action_id=(obj) click to toggle source
# File lib/slack/block_kit/element.rb, line 17
def action_id=(obj)
  raise TypeError, 'action_id must be a string' unless action_id.respond_to?(:to_str)
  raise RangeError, 'action_id must be max 255 characters' unless action_id.size <= 255

  @action_id = obj.to_s
end
to_h() click to toggle source
# File lib/slack/block_kit/element.rb, line 35
def to_h
  { type: type,
    action_id: action_id }
end
type() click to toggle source
# File lib/slack/block_kit/element.rb, line 24
def type
  @type ||= self.class.name
    .split('::')
    .last.chomp('Element')
    .gsub(/([a-z])([A-Z])/, '\1_\2').downcase
end
valid?() click to toggle source
# File lib/slack/block_kit/element.rb, line 31
def valid?
  true
end