abstract struct Decorator::Base

Defined in:

decorator/base.cr

Constructors

Macro Summary

Constructor Detail

def self.new #

[View source]

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 (or getter? for Bool types) for @time

Implementation is heavily inspired by the [Lucky::Assignable] module: https://github.com/luckyframework/lucky/blob/master/src/lucky/assignable.cr


[View source]