Class: Webhookdb::Replicator::WebhookRequest

Inherits:
TypedStruct
  • Object
show all
Defined in:
lib/webhookdb/replicator/webhook_request.rb

Constant Summary collapse

JSON_KEYS =
["body", "headers", "path", "method"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TypedStruct

#[], #_apply, #_defaults, #change, #initialize

Constructor Details

This class inherits a constructor from Webhookdb::TypedStruct

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/webhookdb/replicator/webhook_request.rb', line 4

def body
  @body
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/webhookdb/replicator/webhook_request.rb', line 4

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/webhookdb/replicator/webhook_request.rb', line 4

def method
  @method
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/webhookdb/replicator/webhook_request.rb', line 4

def path
  @path
end

#rack_requestObject

When a webhook is processed synchronously, this will be set to the Rack::Request. Normal (async) webhook processing does not have this available.



8
9
10
# File 'lib/webhookdb/replicator/webhook_request.rb', line 8

def rack_request
  @rack_request
end

Instance Method Details

#as_jsonObject



11
12
13
14
15
16
# File 'lib/webhookdb/replicator/webhook_request.rb', line 11

def as_json
  return JSON_KEYS.each_with_object({}) do |k, h|
    v = self.send(k)
    h[k] = v.as_json unless v.nil?
  end
end