Class: Card::Set::Event

Inherits:
Object show all
Includes:
Callbacks, DelayedEvent, Options
Defined in:
card/lib/card/set/event.rb,
card/lib/card/set/event/all.rb,
card/lib/card/set/event/options.rb,
card/lib/card/set/event/callbacks.rb,
card/lib/card/set/event/delayed_event.rb,
card/lib/card/set/event/skip_and_trigger.rb

Overview

Supports the definition of events via the Events API

Defined Under Namespace

Modules: All, Api, Callbacks, DelayedEvent, Options, SkipAndTrigger

Constant Summary collapse

CONDITIONS =
::Set.new(Api::OPTIONS.keys).freeze

Constants included from DelayedEvent

DelayedEvent::DELAY_STAGES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

#set_event_callback, #set_event_callbacks, #valid_event_callback

Methods included from Options

#callback_name, #event_opts, #invalid_condition_values, #normalize_opts, #process_action_opts, #process_stage_opts, #validate_condition_name, #validate_condition_value, #validate_conditions, #validate_standard_condition_value, #validate_when_value

Methods included from DelayedEvent

#priority

Constructor Details

#initialize(event, stage_or_opts, opts, set_module, &final) ⇒ Event

Returns a new instance of Event.



85
86
87
88
89
90
# File 'card/lib/card/set/event.rb', line 85

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

#optsObject (readonly)

Returns the value of attribute opts.



83
84
85
# File 'card/lib/card/set/event.rb', line 83

def opts
  @opts
end

#set_moduleObject (readonly)

Returns the value of attribute set_module.



83
84
85
# File 'card/lib/card/set/event.rb', line 83

def set_module
  @set_module
end

Instance Method Details

#blockObject



104
105
106
# File 'card/lib/card/set/event.rb', line 104

def block
  @event_block
end

#delaying_method_nameObject

the name for the method that adds the event to the delayed job queue



116
117
118
# File 'card/lib/card/set/event.rb', line 116

def delaying_method_name
  "#{@event}_with_delay"
end

#nameObject

Returns the name of the event.

Returns:

  • the name of the event



100
101
102
# File 'card/lib/card/set/event.rb', line 100

def name
  @event
end

#registerObject



92
93
94
95
96
97
# File 'card/lib/card/set/event.rb', line 92

def register
  validate_conditions
  Card.define_callbacks @event
  define_event
  set_event_callbacks
end

#simple_method_nameObject

the name for the method that only executes the code defined in the event



110
111
112
# File 'card/lib/card/set/event.rb', line 110

def simple_method_name
  "#{@event}_without_callbacks"
end