Class: Euston::Event
- Inherits:
-
Object
- Object
- Euston::Event
- Defined in:
- lib/euston/event.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ Event
constructor
A new instance of Event.
- #to_hash ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Event
Returns a new instance of Event.
3 4 5 6 7 8 9 10 |
# File 'lib/euston/event.rb', line 3 def initialize data = {} if (data.keys & ['body', 'headers']).size == 2 @body, @headers = data.values_at 'body', 'headers' else @headers = {} @body = data end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/euston/event.rb', line 12 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
12 13 14 |
# File 'lib/euston/event.rb', line 12 def headers @headers end |
Instance Method Details
#to_hash ⇒ Object
14 15 16 |
# File 'lib/euston/event.rb', line 14 def to_hash { :headers => @headers, :body => @body } end |