Class: CloudEvents::Event::Opaque
- Inherits:
-
Object
- Object
- CloudEvents::Event::Opaque
- Defined in:
- lib/cloud_events/event/opaque.rb
Overview
This object represents opaque event data that arrived in structured content mode but was not in a recognized format. It may represent a single event or a batch of events.
The event data is retained in a form that can be reserialized (in a structured cotent mode in the same format) but cannot otherwise be inspected.
This object is immutable, and Ractor-shareable on Ruby 3.
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
The opaque serialized event data.
-
#content_type ⇒ CloudEvents::ContentType?
readonly
The content type, or
nil
if there is no content type.
Instance Method Summary collapse
-
#batch? ⇒ boolean?
Whether this represents a batch, or
nil
if not known. -
#initialize(content, content_type, batch: nil) ⇒ Opaque
constructor
Create an opaque object wrapping the given content and a content type.
Constructor Details
#initialize(content, content_type, batch: nil) ⇒ Opaque
Create an opaque object wrapping the given content and a content type.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cloud_events/event/opaque.rb', line 27 def initialize content, content_type, batch: nil @content = content.freeze @content_type = content_type if batch.nil? && content_type&.media_type == "application" case content_type.subtype_base when "cloudevents" batch = false when "cloudevents-batch" batch = true end end @batch = batch freeze end |
Instance Attribute Details
#content ⇒ String (readonly)
The opaque serialized event data
47 48 49 |
# File 'lib/cloud_events/event/opaque.rb', line 47 def content @content end |
#content_type ⇒ CloudEvents::ContentType? (readonly)
The content type, or nil
if there is no content type.
54 55 56 |
# File 'lib/cloud_events/event/opaque.rb', line 54 def content_type @content_type end |
Instance Method Details
#batch? ⇒ boolean?
Whether this represents a batch, or nil
if not known.
61 62 63 |
# File 'lib/cloud_events/event/opaque.rb', line 61 def batch? @batch end |