Class: ROM::Notifications::Event

Inherits:
Object
  • Object
show all
Defined in:
core/lib/rom/support/notifications.rb

Overview

Event object

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)



84
85
86
# File 'core/lib/rom/support/notifications.rb', line 84

def id
  @id
end

Instance Method Details

#[](name) ⇒ Object

Get data from the payload

Parameters:

  • name (String, Symbol)


104
105
106
# File 'core/lib/rom/support/notifications.rb', line 104

def [](name)
  @payload.fetch(name)
end

#Hash #payload(data) ⇒ Event

Get or set a payload

Overloads:

  • #Hash

    Returns payload.

    Returns:

    • (Hash)

      payload

  • #payload(data) ⇒ Event

    Returns A copy of the event with the provided payload.

    Parameters:

    • data (Hash)

      A new payload

    Returns:

    • (Event)

      A copy of the event with the provided payload



128
129
130
131
132
133
134
# File 'core/lib/rom/support/notifications.rb', line 128

def payload(data = nil)
  if data
    self.class.new(id, @payload.merge(data))
  else
    @payload
  end
end

#to_hHash Also known as: to_hash

Coerce an event to a hash

Returns:

  • (Hash)


113
114
115
# File 'core/lib/rom/support/notifications.rb', line 113

def to_h
  @payload
end