Class: EvilEvents::Core::Broadcasting::Emitter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evil_events/core/broadcasting/emitter.rb,
lib/evil_events/core/broadcasting/emitter/adapter_proxy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Defined Under Namespace

Classes: AdapterProxy

Instance Method Summary collapse

Instance Method Details

#emit(event, adapter: nil) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

Options Hash (adapter:):

  • (Symbol, NilClass)

Raises:

Since:

  • 0.1.0


13
14
15
16
17
18
19
20
21
22
# File 'lib/evil_events/core/broadcasting/emitter.rb', line 13

def emit(event, adapter: nil)
  unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
    raise EvilEvents::IncorrectEventForEmitError
  end

  adapter_proxy = AdapterProxy.new(event, explicit_identifier: adapter)

  log_activity(event, adapter_proxy)
  adapter_proxy.broadcast!
end

#log_activity(event, adapter_proxy) ⇒ void (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.


47
48
49
50
51
52
53
54
55
# File 'lib/evil_events/core/broadcasting/emitter.rb', line 47

def log_activity(event, adapter_proxy)
  activity = "EventEmitted(#{adapter_proxy.identifier})"
  message  = "ID: #{event.id} :: " \
             "TYPE: #{event.type} :: " \
             "PAYLOAD: #{event.payload} :: " \
             "METADATA: #{event.}"

  EvilEvents::Core::ActivityLogger.log(activity: activity, message: message)
end

#raw_emit(event_type, id: nil, payload: {}, metadata: {}, adapter: nil) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • event_type (String)
  • id (Hash) (defaults to: nil)

    a customizable set of options

  • payload (Hash) (defaults to: {})

    a customizable set of options

  • metadata (Hash) (defaults to: {})

    a customizable set of options

  • adapter (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (id:):

  • (NilClass, String)

Options Hash (payload:):

  • (Hash)

Options Hash (metadata:):

  • (Hash)

Options Hash (adapter:):

  • (Symbol, NilClass)

Since:

  • 0.1.0


32
33
34
35
36
37
38
# File 'lib/evil_events/core/broadcasting/emitter.rb', line 32

def raw_emit(event_type, id: nil, payload: {}, metadata: {}, adapter: nil)
  event_object = EvilEvents::Core::Bootstrap[:event_system].resolve_event_object(
    event_type, id: id, payload: payload, metadata: 
  )

  emit(event_object, adapter: adapter)
end