class

Clear::Model::EventManager

Inherits Reference < Object

Global storage for model lifecycle event management

This class acts as a storage and can trigger events This class a singleton.

Constants

EVENT_CALLBACKS = {} of EventKey => Array(HookFunction)
INHERITANCE_MAP = {} of String => String

Class methods

add_inheritance(parent, child)

Map the inheritance between models. Events which belongs to parent model are triggered when child model lifecycle actions occurs

Source
attach(klazz, direction : Symbol, event : Symbol, block : HookFunction)

Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)

Source
has_trigger?(klazz, direction : Symbol, event : Symbol)
Source
trigger(klazz, direction : Symbol, event : Symbol, mdl : Clear::Model)

Trigger events callback for a specific model. Direction can be :before and :after In case of :before direction, the events are called in reverse order:

before:
- Last defined event
- First defined event
action
after:
- First defined events
- Last defined events
Source

Nested types