Class: Euston::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/euston/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



12
13
14
# File 'lib/euston/event.rb', line 12

def body
  @body
end

#headersObject (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_hashObject



14
15
16
# File 'lib/euston/event.rb', line 14

def to_hash
  { :headers => @headers, :body => @body }
end