Module: Card::Set::Event::Api
- Included in:
- Card::Set
- Defined in:
- card/lib/card/set/event.rb
Overview
Events are the building blocks of the three transformative card actions: create, update, and delete.
(The fourth kind of action, read, does not transform cards, and is associated with views, not events).
As described in detail in Director, each act can have many actions, each action has three phases, each phase has three stages, and each stage has many events.
Events are defined in set modules in mods. Learn more about set modules.
A simple event definition looks something like this:
event :append_you_know, :prepare_to_validate, on: :create do
self.content = content + ", you know?"
end
Note:
:append_you_know
is a unique event name.:prepare_to_validate
is a stage.on: :create
specifies the action to which the event appliesself
, within the event card, is a card object.
Any card within the set on which this event is defined will
run this event during the prepare_to_validate
stage when it is created.
Events should not be defined within format blocks.
Constant Summary collapse
- OPTIONS =
{ on: %i[create update delete save read], changed: Card::Dirty., changing: Card::Dirty., skip: [:allowed], trigger: [:required], when: nil }.freeze
Instance Method Summary collapse
-
#event(event, stage_or_opts = {}, opts = {}, &final) ⇒ Object
Define an event for a set of cards.