abstract struct Decorator::Base
- Decorator::Base
- Struct
- Value
- Object
Defined in:
decorator/base.crConstructors
Instance Method Summary
Macro Summary
-
decorates(type_declaration)
The
decorates
macro defines all of the Decorator core logic.
Constructor Detail
Instance Method Detail
Macro Detail
macro decorates(type_declaration)
#
The decorates
macro defines all of the Decorator core logic.
Currently, you can only supply one decorates
statement per decorator
that inherits from Decorator::Base
.
Given a decorator struct like this:
struct TimeDecorator < Decorator::Base
decorates time : Time
end
The following items are made available to the TimeDecorator
struct:
- An
initialize(@time : Time)
method - A
collection(objects : Array(Time))
class method - A
getter
(orgetter?
forBool
types) for@time
Implementation is heavily inspired by the [Lucky::Assignable] module: https://github.com/luckyframework/lucky/blob/master/src/lucky/assignable.cr