Class: Toot::Event
- Inherits:
-
Object
- Object
- Toot::Event
- Defined in:
- lib/toot/event.rb
Constant Summary collapse
- DEFAULTS =
-> { { id: SecureRandom.uuid, timestamp: Time.now, payload: {}, } }
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#id ⇒ Object
Returns the value of attribute id.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
-
#initialize(args = {}) ⇒ Event
constructor
A new instance of Event.
- #publish ⇒ Object
- #to_h ⇒ Object
Constructor Details
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
6 7 8 |
# File 'lib/toot/event.rb', line 6 def channel @channel end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/toot/event.rb', line 6 def id @id end |
#payload ⇒ Object
Returns the value of attribute payload.
6 7 8 |
# File 'lib/toot/event.rb', line 6 def payload @payload end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/toot/event.rb', line 6 def @timestamp end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/toot/event.rb', line 38 def ==(other) self.id == other.id end |
#[](key) ⇒ Object
42 43 44 |
# File 'lib/toot/event.rb', line 42 def [](key) payload[key] end |
#publish ⇒ Object
24 25 26 27 |
# File 'lib/toot/event.rb', line 24 def publish PublishesEvent.perform_async(to_h) self end |
#to_h ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/toot/event.rb', line 29 def to_h { id: id, timestamp: , payload: payload, channel: channel, } end |