Module: EvilEvents::Core::Events::EventExtensions::Payloadable::ClassMethods Private

Defined in:
lib/evil_events/core/events/event_extensions/payloadable.rb

Overview

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

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#inherited(child_class) ⇒ Object

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.

Parameters:

  • child_class (Class)

Since:

  • 0.1.0



30
31
32
33
# File 'lib/evil_events/core/events/event_extensions/payloadable.rb', line 30

def inherited(child_class)
  child_class.const_set(:Payload, Class.new(AbstractPayload))
  super
end

#payload(key, type = EvilEvents::Types::Any, **options) ⇒ Object

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.

Returns void.

Parameters:

  • key (Symbol)
  • type (EvilEvents::Shared::Types::Any) (defaults to: EvilEvents::Types::Any)
  • options (Hash)

Returns:

  • void

Since:

  • 0.1.0



48
49
50
51
52
53
54
# File 'lib/evil_events/core/events/event_extensions/payloadable.rb', line 48

def payload(key, type = EvilEvents::Types::Any, **options)
  if type.is_a?(Symbol)
    type = EvilEvents::Core::Bootstrap[:event_system].resolve_type(type, **options)
  end

  payload_class.attribute(key, type)
end

#payload_classClass{AbstractPayload}

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.

Returns:

Since:

  • 0.2.0



38
39
40
# File 'lib/evil_events/core/events/event_extensions/payloadable.rb', line 38

def payload_class
  const_get(:Payload)
end

#payload_fieldsArray<Symbol>

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.

Returns:

  • (Array<Symbol>)

Since:

  • 0.1.0



59
60
61
# File 'lib/evil_events/core/events/event_extensions/payloadable.rb', line 59

def payload_fields
  payload_class.attribute_names
end