diff --git a/src/main/kotlin/no/telenor/slack/meta/Blocks.kt b/src/main/kotlin/no/telenor/slack/meta/Blocks.kt index 22aff5f..ce98028 100644 --- a/src/main/kotlin/no/telenor/slack/meta/Blocks.kt +++ b/src/main/kotlin/no/telenor/slack/meta/Blocks.kt @@ -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> { internal val elements = mutableListOf() internal fun add(block: LayoutBlock) { @@ -21,4 +22,10 @@ class Blocks { operator fun Into.unaryPlus() { elements.add(into()) } + + override fun into() = elements.toImmutableList() + + companion object { + fun with(block: Blocks.() -> Unit) = Blocks().apply(block).into() + } }