Class: FaaStRuby::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/faastruby/spec_helper.rb,
lib/faastruby/server/event.rb

Overview

Add default initialize values to the Event class for backwards compatibility. This will be removed on v0.6

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, query_params:, headers:, context:) ⇒ Event

Returns a new instance of Event.



22
23
24
25
26
27
# File 'lib/faastruby/spec_helper.rb', line 22

def initialize(body: nil, query_params: {}, headers: {}, context: nil)
  @body = body
  @query_params = query_params
  @headers = headers
  @context = context
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/faastruby/server/event.rb', line 3

def body
  @body
end

#contextObject

Returns the value of attribute context.



3
4
5
# File 'lib/faastruby/server/event.rb', line 3

def context
  @context
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/faastruby/server/event.rb', line 3

def headers
  @headers
end

#query_paramsObject

Returns the value of attribute query_params.



3
4
5
# File 'lib/faastruby/server/event.rb', line 3

def query_params
  @query_params
end

Instance Method Details

#to_hObject



10
11
12
13
14
15
16
17
# File 'lib/faastruby/server/event.rb', line 10

def to_h
  {
    "body" => @body,
    "query_params" => @query_params,
    "headers" => @headers,
    "context" => @context
  }
end

#to_jsonObject



18
19
20
# File 'lib/faastruby/server/event.rb', line 18

def to_json
  Oj.dump(to_h)
end