diff --git a/bar.go b/bar.go index 2eb74e2..eda7f20 100644 --- a/bar.go +++ b/bar.go @@ -78,7 +78,6 @@ noPop bool aDecorators []decor.Decorator pDecorators []decor.Decorator - mDecorators []decor.Decorator amountReceivers []decor.AmountReceiver shutdownListeners []decor.ShutdownListener averageAdjusters []decor.AverageAdjuster @@ -196,10 +195,9 @@ for _, decorators := range [...][]decor.Decorator{ s.pDecorators, s.aDecorators, - s.mDecorators, } { for _, d := range decorators { - cb(d) + cb(extractBaseDecorator(d)) } } } @@ -462,3 +460,10 @@ Current: s.current, } } + +func extractBaseDecorator(d decor.Decorator) decor.Decorator { + if d, ok := d.(decor.Wrapper); ok { + return extractBaseDecorator(d.Base()) + } + return d +} diff --git a/decor/decorator.go b/decor/decorator.go index 5190b35..a3d04da 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -72,6 +72,14 @@ type Configurator interface { GetConf() WC SetConf(*WC) +} + +// Wrapper interface. +// If you're implementing custom Decorator by wrapping a built-in one, +// it is necessary to implement this interface to retain functionality +// of built-in Decorator. +type Wrapper interface { + Base() Decorator } // AmountReceiver interface.