Class: Slack::BlockKit::Layout::RichText::RichTextElements::User

Inherits:
Object
  • Object
show all
Includes:
StyleHelper
Defined in:
lib/slack/block_kit/layout/rich_text/rich_text_elements/user.rb

Overview

Constant Summary collapse

TYPE =
'user'
VALID_STYLES =
%w[bold italic strike highlight client_highlight unlink].freeze

Instance Method Summary collapse

Methods included from StyleHelper

#styles_as_json, #validate_styles

Constructor Details

#initialize(user_id:, styles: []) ⇒ User

Returns a new instance of User.



14
15
16
17
18
# File 'lib/slack/block_kit/layout/rich_text/rich_text_elements/user.rb', line 14

def initialize(user_id:, styles: [])
  @user_id = user_id
  @styles = styles
  validate_styles(styles, VALID_STYLES)
end

Instance Method Details

#as_jsonObject



20
21
22
23
24
25
26
# File 'lib/slack/block_kit/layout/rich_text/rich_text_elements/user.rb', line 20

def as_json(*)
  {
    type: TYPE,
    user_id: @user_id,
    style: styles_as_json(@styles)
  }.compact
end