Class: Low::Events::HiddenEvent

Inherits:
Object
  • Object
show all
Includes:
LowType
Defined in:
lib/events/hidden_event.rb

Overview

An event that happens on event tree branching and isn’t added to the event tree/sequence.

Direct Known Subclasses

BranchEvent

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, action: nil) ⇒ HiddenEvent

Returns a new instance of HiddenEvent.



13
14
15
16
17
# File 'lib/events/hidden_event.rb', line 13

def initialize(key:, action: nil)
  @key = key
  @action = action
  @created_at = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



11
12
13
# File 'lib/events/hidden_event.rb', line 11

def action
  @action
end

#created_atObject (readonly)

Returns the value of attribute created_at.



11
12
13
# File 'lib/events/hidden_event.rb', line 11

def created_at
  @created_at
end

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/events/hidden_event.rb', line 11

def key
  @key
end

Class Method Details

.inherited(child) ⇒ Object



30
31
32
# File 'lib/events/hidden_event.rb', line 30

def inherited(child)
  child.include LowType
end

.trigger(**kwargs) ⇒ Object



26
27
28
# File 'lib/events/hidden_event.rb', line 26

def trigger(**kwargs)
  new(**kwargs).trigger
end

Instance Method Details

#triggerObject



19
20
21
22
23
# File 'lib/events/hidden_event.rb', line 19

def trigger
  event_tree = branch
  key = Observers::Keys[@key]
  key.trigger(event: self) { restore_level(event_tree:) }
end