class PubSub::EventEmission
Constants
- EventPayloadArgumentMissing
Attributes
context[R]
event_class[R]
explicit_payload[R]
Public Class Methods
new(event_class, explicit_payload, context)
click to toggle source
# File lib/pub_sub/event_emission.rb, line 7 def initialize(event_class, explicit_payload, context) @event_class = event_class @explicit_payload = explicit_payload @context = context end
Public Instance Methods
call()
click to toggle source
# File lib/pub_sub/event_emission.rb, line 13 def call event_class.new(full_payload).broadcast! end
Private Instance Methods
event_payload_attribute_names()
click to toggle source
# File lib/pub_sub/event_emission.rb, line 21 def event_payload_attribute_names event_class.attribute_names end
full_payload()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/pub_sub/event_emission.rb, line 26 def full_payload event_payload_attribute_names.each_with_object({}) do |attribute_name, result| result[attribute_name] = PayloadAttribute.new(attribute_name, explicit_payload, context).get rescue PayloadAttribute::CannotEvaluate => cannot_evaluate_error if event_class.schema.key(attribute_name).default? next else raise( EventPayloadArgumentMissing, "Event [#{event_class.name}] expects [#{attribute_name}] payload attribute to be" \ " either exposed as [#{cannot_evaluate_error.message}] method in emitting object" \ ' or provided as argument' ) end end end