Class: ROM::Notifications::Event
- Inherits:
-
Object
- Object
- ROM::Notifications::Event
- Defined in:
- core/lib/rom/support/notifications.rb
Overview
Event object
Instance Attribute Summary collapse
- #id ⇒ Object readonly
Instance Method Summary collapse
-
#[](name) ⇒ Object
Get data from the payload.
-
#payload(data = nil) ⇒ Object
Get or set a payload.
-
#to_h ⇒ Hash
(also: #to_hash)
Coerce an event to a hash.
Instance Attribute Details
#id ⇒ Object (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
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
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_h ⇒ Hash Also known as: to_hash
Coerce an event to a hash
113 114 115 |
# File 'core/lib/rom/support/notifications.rb', line 113 def to_h @payload end |