Class: Esse::Events::Event
- Inherits:
-
Object
- Object
- Esse::Events::Event
- Extended by:
- Forwardable
- Defined in:
- lib/esse/events/event.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id, payload = {}) ⇒ Event
constructor
private
Initialize a new event.
- #listener_method ⇒ Object private
-
#payload(data = nil) ⇒ Object
Get or set a payload.
Constructor Details
#initialize(id, payload = {}) ⇒ Event
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.
Initialize a new event
20 21 22 23 |
# File 'lib/esse/events/event.rb', line 20 def initialize(id, payload = {}) @id = id @payload = payload end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/esse/events/event.rb', line 10 def id @id end |
Instance Method Details
#listener_method ⇒ 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.
44 45 46 |
# File 'lib/esse/events/event.rb', line 44 def listener_method @listener_method ||= Hstring.new("on_#{id}").underscore.to_sym end |
# ⇒ Hash #payload(data) ⇒ Event
Get or set a payload
35 36 37 38 39 40 41 |
# File 'lib/esse/events/event.rb', line 35 def payload(data = nil) if data self.class.new(id, @payload.merge(data)) else @payload end end |