Class: EventEngine::CatalogEntry
- Inherits:
-
Struct
- Object
- Struct
- EventEngine::CatalogEntry
- Defined in:
- lib/event_engine/catalog_entry.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#event_name ⇒ Object
Returns the value of attribute event_name.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#event_version ⇒ Object
Returns the value of attribute event_version.
-
#optional_inputs ⇒ Object
Returns the value of attribute optional_inputs.
-
#payload_fields ⇒ Object
Returns the value of attribute payload_fields.
-
#required_inputs ⇒ Object
Returns the value of attribute required_inputs.
-
#subject ⇒ Object
Returns the value of attribute subject.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def domain @domain end |
#event_name ⇒ Object
Returns the value of attribute event_name
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def event_name @event_name end |
#event_type ⇒ Object
Returns the value of attribute event_type
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def event_type @event_type end |
#event_version ⇒ Object
Returns the value of attribute event_version
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def event_version @event_version end |
#optional_inputs ⇒ Object
Returns the value of attribute optional_inputs
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def optional_inputs @optional_inputs end |
#payload_fields ⇒ Object
Returns the value of attribute payload_fields
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def payload_fields @payload_fields end |
#required_inputs ⇒ Object
Returns the value of attribute required_inputs
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def required_inputs @required_inputs end |
#subject ⇒ Object
Returns the value of attribute subject
5 6 7 |
# File 'lib/event_engine/catalog_entry.rb', line 5 def subject @subject end |
Class Method Details
.from_h(hash) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/event_engine/catalog_entry.rb', line 17 def self.from_h(hash) h = hash.transform_keys(&:to_sym) new( event_name: h[:event_name]&.to_sym, event_version: h[:event_version], event_type: h[:event_type]&.to_sym, subject: h[:subject]&.to_sym, domain: h[:domain]&.to_sym, required_inputs: Array(h[:required_inputs]).map(&:to_sym), optional_inputs: Array(h[:optional_inputs]).map(&:to_sym), payload_fields: Array(h[:payload_fields]).map { |field| payload_field_from_h(field) } ) end |
.payload_field_from_h(field) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/event_engine/catalog_entry.rb', line 32 def self.payload_field_from_h(field) f = field.transform_keys(&:to_sym) { name: f[:name]&.to_sym, required: f[:required], from: f[:from]&.to_sym, attr: f[:attr]&.to_sym } end |
Instance Method Details
#fingerprint ⇒ Object
43 44 45 |
# File 'lib/event_engine/catalog_entry.rb', line 43 def fingerprint Digest::SHA256.hexdigest(canonical_representation) end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/event_engine/catalog_entry.rb', line 47 def to_h { event_name: event_name, event_version: event_version, event_type: event_type, subject: subject, domain: domain, required_inputs: required_inputs, optional_inputs: optional_inputs, payload_fields: payload_fields.map { |field| payload_field_h(field) }, fingerprint: fingerprint } end |