Class: Card::Set::Event

Inherits:
Object
  • Object
show all
Includes:
Callbacks, DelayedEvent, Options
Defined in:
lib/card/set/event.rb,
lib/card/set/event/all.rb,
lib/card/set/event/options.rb,
lib/card/set/event/callbacks.rb,
lib/card/set/event/delayed_event.rb,
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, set_module) ⇒ Event

Returns a new instance of Event.



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

def initialize event, set_module
  @event = event
  @set_module = set_module
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



83
84
85
# File '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 'lib/card/set/event.rb', line 83

def set_module
  @set_module
end

Instance Method Details

#blockObject



108
109
110
# File 'lib/card/set/event.rb', line 108

def block
  @event_block
end

#defineObject



97
98
99
100
101
# File 'lib/card/set/event.rb', line 97

def define
  Card.define_callbacks @event
  define_event
  set_event_callbacks
end

#delaying_method_nameObject

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



120
121
122
# File 'lib/card/set/event.rb', line 120

def delaying_method_name
  "#{@event}_with_delay"
end

#nameObject

Returns the name of the event.

Returns:

  • the name of the event



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

def name
  @event
end

#register(stage_or_opts, opts, &final) ⇒ Object



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

def register stage_or_opts, opts, &final
  @opts = event_opts stage_or_opts, opts
  @event_block = final
  validate_conditions
  define
end

#simple_method_nameObject

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



114
115
116
# File 'lib/card/set/event.rb', line 114

def simple_method_name
  "#{@event}_without_callbacks"
end