module CloudEvents
CloudEvents
implementation.
This is a Ruby implementation of the [CloudEvents](cloudevents.io) specification. It supports both [CloudEvents 0.3](github.com/cloudevents/spec/blob/v0.3/spec.md) and [CloudEvents 1.0](github.com/cloudevents/spec/blob/v1.0/spec.md).
Constants
- HttpContentError
An error raised when a protocol binding was asked to decode a CloudEvent from input data, and the data appears to be a CloudEvent, but was encoded in a format that is not supported. Some protocol bindings can be configured to return a {CloudEvents::Event::Opaque} object instead of raising this error.
- SUPPORTED_SPEC_VERSIONS
@private
- UNDEFINED
- VERSION
Version of the Ruby
CloudEvents
SDK @return [String]
Public Class Methods
supported_spec_versions()
click to toggle source
The spec versions supported by this implementation.
@return [Array<String>]
# File lib/cloud_events.rb, line 29 def supported_spec_versions SUPPORTED_SPEC_VERSIONS end
Public Instance Methods
data_object(keys, required: false)
click to toggle source
# File lib/cloud_events/event/field_interpreter.rb, line 108 def data_object keys, required: false object keys, required: required, allow_nil: true do |value| Utils.deep_freeze value [value, value] end end
Private Instance Methods
object(keys, required: false, allow_nil: false) { |value| ... }
click to toggle source
# File lib/cloud_events/event/field_interpreter.rb, line 119 def object keys, required: false, allow_nil: false value = UNDEFINED keys.each do |key| key_present = @args.key? key val = @args.delete key value = val if allow_nil && key_present || !allow_nil && !val.nil? end if value == UNDEFINED raise AttributeError, "The #{keys.first} field is required" if required return allow_nil ? UNDEFINED : nil end converted, raw = yield value @attributes[keys.first.freeze] = raw converted end