Class: Card::Set::Event
- Inherits:
-
Object
- Object
- Card::Set::Event
- Includes:
- Callbacks, DelayedEvent, Options
- Defined in:
- lib/card/set/event.rb,
lib/card/set/event/options.rb,
lib/card/set/event/callbacks.rb,
lib/card/set/event/delayed_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).
Whenever you create, update, or delete a card, the card goes through three phases:
- validate makes sure all the data is in order
- store puts the data in the database
- integrate deals with any ramifications of those changes
Events can be defined on each of these stages
Defined Under Namespace
Modules: Api, Callbacks, DelayedEvent, Options
Constant Summary collapse
- CONDITION_OPTIONS =
{ on: %i[create update delete save read], changed: %i[name content db_content type type_id codename key], changing: %i[name content db_content type type_id codename key], skip: :allowed, trigger: :required # the event is only executed if triggered explicitly with # trigger: [event_name] }.freeze
- CONDITIONS =
::Set.new(%i[on changed changing when skip trigger]).freeze
Constants included from DelayedEvent
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#set_module ⇒ Object
readonly
Returns the value of attribute set_module.
Instance Method Summary collapse
- #block ⇒ Object
-
#delaying_method_name ⇒ Object
the name for the method that adds the event to the delayed job queue.
-
#initialize(event, stage_or_opts, opts, set_module, &final) ⇒ Event
constructor
A new instance of Event.
-
#name ⇒ Object
The name of the event.
- #register ⇒ Object
-
#simple_method_name ⇒ Object
the name for the method that only executes the code defined in the event.
Methods included from Callbacks
#set_event_callback, #set_event_callbacks, #valid_event_callback
Methods included from Options
#callback_name, #event_opts, #normalize_opts, #process_action_opts, #process_stage_opts, #valid_values, #validate_condition_name, #validate_condition_value, #validate_conditions, #validate_when_value
Constructor Details
#initialize(event, stage_or_opts, opts, set_module, &final) ⇒ Event
Returns a new instance of Event.
40 41 42 43 44 45 |
# File 'lib/card/set/event.rb', line 40 def initialize event, stage_or_opts, opts, set_module, &final @event = event @set_module = set_module @opts = event_opts stage_or_opts, opts @event_block = final end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
38 39 40 |
# File 'lib/card/set/event.rb', line 38 def opts @opts end |
#set_module ⇒ Object (readonly)
Returns the value of attribute set_module.
38 39 40 |
# File 'lib/card/set/event.rb', line 38 def set_module @set_module end |
Instance Method Details
#block ⇒ Object
59 60 61 |
# File 'lib/card/set/event.rb', line 59 def block @event_block end |
#delaying_method_name ⇒ Object
the name for the method that adds the event to the delayed job queue
71 72 73 |
# File 'lib/card/set/event.rb', line 71 def "#{@event}_with_delay" end |
#name ⇒ Object
Returns the name of the event.
55 56 57 |
# File 'lib/card/set/event.rb', line 55 def name @event end |
#register ⇒ Object
47 48 49 50 51 52 |
# File 'lib/card/set/event.rb', line 47 def register validate_conditions Card.define_callbacks @event define_event set_event_callbacks end |
#simple_method_name ⇒ Object
the name for the method that only executes the code defined in the event
65 66 67 |
# File 'lib/card/set/event.rb', line 65 def simple_method_name "#{@event}_without_callbacks" end |