From e159a4defc639640f41efa3879bb9187761237f7 Mon Sep 17 00:00:00 2001 From: Sven Greb Date: Mon, 23 Nov 2020 15:50:12 +0100 Subject: [PATCH] Spell incantation options "mixin" To allow to compose, manipulate and read spell incantation options afte the initial creation, two new types will be added for the spell packages [1]: - `spell.Options` - A `interface` type as a generic representation for `spell.Incantation` options. - `spell.Mixin` - A `interface` type that allows to compose functions that process `spell.Options` of `spell.Incantation`s. - `Apply(Options) (Options, error)` - applies generic `spell.Options` to `spell.Incantation` options. [1]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell GH-25 --- pkg/spell/mixin.go | 13 +++++++++++++ pkg/spell/spell.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 pkg/spell/mixin.go diff --git a/pkg/spell/mixin.go b/pkg/spell/mixin.go new file mode 100644 index 0000000..981f35f --- /dev/null +++ b/pkg/spell/mixin.go @@ -0,0 +1,13 @@ +// Copyright (c) 2019-present Sven Greb +// This source code is licensed under the MIT license found in the LICENSE file. + +package spell + +// Options is a generic representation for spell incantation options. +type Options interface{} + +// Mixin allows to compose functions that process Options of spell incantations. +type Mixin interface { + // Apply applies generic Options to spell incantation options. + Apply(Options) (Options, error) +} diff --git a/pkg/spell/spell.go b/pkg/spell/spell.go index a53fbbb..40b449b 100644 --- a/pkg/spell/spell.go +++ b/pkg/spell/spell.go @@ -30,7 +30,7 @@ type Incantation interface { // Kind returns the Kind of a spell. Kind() Kind - // Options return the options of a spell. + // Options returns the options of a spell. Options() interface{} }