enhancing

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package enhancing allows for enhancement of model instances with your custom data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustUnwrap

func MustUnwrap[E any](that aastypes.IClass) (enhancement E)

Retrieve the enhancement from `that` instance.

If `that` instance has not been enhanced yet, panic.

func Unwrap

func Unwrap[E any](that aastypes.IClass) (enhancement E, ok bool)

Retrieve the enhancement from `that` instance.

Return the enhancement, or `ok` false, if `that` instance has not been enhanced.

func Wrap

func Wrap[E any](
	that aastypes.IClass,
	factory func(aastypes.IClass) (E, bool),
) (result aastypes.IClass)

Wrap `that` instance recursively with the enhancement produced by the `factory`.

The factory returns the enhancement, and a boolean "should-enhance". If the "should-enhance" is false, `that` instance is not enhance, and we simply return it. However, we will still continue to enhance the instances referenced by `that` instance recursively.

If `that` instance has been already wrapped, panic.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL