Class: Downstream::DataEvent
- Defined in:
- lib/downstream/data_event.rb
Constant Summary
Constants inherited from Event
Class Attribute Summary collapse
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(event_id: nil, **attrs) ⇒ DataEvent
constructor
A new instance of DataEvent.
- #to_h ⇒ Object
Methods inherited from Event
#==, attributes, define, defined_attributes, human_attribute_name, i18n_scope, #inspect, lookup_ancestors, #read_attribute_for_validation, #to_global_id, #type
Constructor Details
#initialize(event_id: nil, **attrs) ⇒ DataEvent
Returns a new instance of DataEvent.
18 19 20 21 22 |
# File 'lib/downstream/data_event.rb', line 18 def initialize(event_id: nil, **attrs) @event_id = event_id || SecureRandom.hex(10) @data = self.class.data_class.new(**attrs) freeze end |
Class Attribute Details
.data_class ⇒ Object
8 9 10 11 12 |
# File 'lib/downstream/data_event.rb', line 8 def data_class return @data_class if @data_class @data_class = superclass.data_class end |
Instance Method Details
#to_h ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/downstream/data_event.rb', line 24 def to_h { type:, event_id:, data: data.to_h.freeze }.freeze end |