Skip to content

Commit f2db70a

Browse files
committed
Allow automatically truncating long Block IDs
1 parent 4a493f1 commit f2db70a

24 files changed

+263
-0
lines changed

lib/slack/block_kit.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ module Layout; end
1010

1111
module_function
1212

13+
def configuration
14+
@configuration ||= Configuration.new
15+
16+
yield(@configuration) if block_given?
17+
18+
@configuration
19+
end
20+
class << self
21+
alias config configuration
22+
end
23+
1324
def blocks
1425
blocks = Blocks.new
1526

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Slack
2+
module BlockKit
3+
class Configuration
4+
attr_accessor :autofix_invalid_blocks
5+
6+
def initialize
7+
@autofix_invalid_blocks = false
8+
end
9+
10+
def autofix_invalid_blocks?
11+
!!@autofix_invalid_blocks
12+
end
13+
end
14+
end
15+
end

lib/slack/block_kit/layout/actions.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Layout
77
#
88
# https://api.slack.com/reference/messaging/blocks#actions
99
class Actions
10+
prepend Limiters::BlockId
1011
TYPE = 'actions'
1112

1213
attr_accessor :elements

lib/slack/block_kit/layout/context.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Layout
77
#
88
# https://api.slack.com/reference/messaging/blocks#context
99
class Context
10+
prepend Limiters::BlockId
1011
TYPE = 'context'
1112

1213
attr_accessor :elements

lib/slack/block_kit/layout/divider.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Layout
88
#
99
# https://api.slack.com/reference/messaging/blocks#divider
1010
class Divider
11+
prepend Limiters::BlockId
1112
TYPE = 'divider'
1213

1314
def initialize(block_id: nil)

lib/slack/block_kit/layout/header.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Layout
99
#
1010
# https://api.slack.com/reference/block-kit/blocks#header
1111
class Header
12+
prepend Limiters::BlockId
1213
TYPE = 'header'
1314

1415
def initialize(text:, block_id: nil, emoji: nil)

lib/slack/block_kit/layout/image.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Layout
77
#
88
# https://api.slack.com/reference/messaging/blocks#context
99
class Image
10+
prepend Limiters::BlockId
1011
TYPE = 'image'
1112

1213
def initialize(url:, alt_text:, title: nil, block_id: nil, emoji: nil)

lib/slack/block_kit/layout/input.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Layout
99
#
1010
# https://api.slack.com/reference/block-kit/blocks#input
1111
class Input # rubocop:disable Metrics/ClassLength
12+
prepend Limiters::BlockId
1213
TYPE = 'input'
1314

1415
attr_accessor :label, :element, :block_id, :hint, :optional, :emoji

lib/slack/block_kit/layout/rich_text.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Layout
1111
#
1212
# https://api.slack.com/reference/block-kit/blocks#rich_text
1313
class RichText
14+
prepend Limiters::BlockId
1415
TYPE = 'rich_text'
1516

1617
attr_accessor :elements

lib/slack/block_kit/layout/section.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Layout
99
#
1010
# https://api.slack.com/reference/messaging/blocks#section
1111
class Section
12+
prepend Limiters::BlockId
1213
include Section::MultiSelectElements
1314
TYPE = 'section'
1415

0 commit comments

Comments
 (0)