Skip to content

Commit

Permalink
feat: Added a way to get the elements out of blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
testersen committed Feb 3, 2024
1 parent 975d9f8 commit 83191b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/kotlin/no/telenor/slack/meta/Blocks.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package no.telenor.slack.meta

import com.slack.api.model.block.LayoutBlock
import okhttp3.internal.toImmutableList

class Blocks {
class Blocks : Into<List<LayoutBlock>> {
internal val elements = mutableListOf<LayoutBlock>()

internal fun add(block: LayoutBlock) {
Expand All @@ -21,4 +22,10 @@ class Blocks {
operator fun Into<LayoutBlock>.unaryPlus() {
elements.add(into())
}

override fun into() = elements.toImmutableList()

companion object {
fun with(block: Blocks.() -> Unit) = Blocks().apply(block).into()
}
}

0 comments on commit 83191b2

Please sign in to comment.