Class: FDK::Context
- Inherits:
-
Object
- Object
- FDK::Context
- Defined in:
- lib/fdk/context.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
CloudEvent format: github.com/cloudevents/spec/blob/master/serialization.md#json.
Instance Method Summary collapse
- #call_id ⇒ Object
-
#cloud_event? ⇒ Boolean
If it’s a CNCF CloudEvent.
- #config ⇒ Object
- #content_type ⇒ Object
-
#initialize(event) ⇒ Context
constructor
A new instance of Context.
- #protocol ⇒ Object
Constructor Details
#initialize(event) ⇒ Context
Returns a new instance of Context.
31 32 33 |
# File 'lib/fdk/context.rb', line 31 def initialize(event) @event = event end |
Instance Attribute Details
#event ⇒ Object (readonly)
CloudEvent format: github.com/cloudevents/spec/blob/master/serialization.md#json
29 30 31 |
# File 'lib/fdk/context.rb', line 29 def event @event end |
Instance Method Details
#call_id ⇒ Object
44 45 46 |
# File 'lib/fdk/context.rb', line 44 def call_id cloud_event? ? event['eventID'] : event['call_id'] end |
#cloud_event? ⇒ Boolean
If it’s a CNCF CloudEvent
36 37 38 |
# File 'lib/fdk/context.rb', line 36 def cloud_event? ENV['FN_FORMAT'] == "cloudevent" end |
#config ⇒ Object
40 41 42 |
# File 'lib/fdk/context.rb', line 40 def config @config ||= Config.new end |
#content_type ⇒ Object
48 49 50 |
# File 'lib/fdk/context.rb', line 48 def content_type cloud_event? ? event['contentType'] : event['content_type'] end |
#protocol ⇒ Object
52 53 54 |
# File 'lib/fdk/context.rb', line 52 def protocol cloud_event? ? event['extensions']['protocol'] : event['protocol'] end |