Class: Midnight::BusinessLogic::Event
- Inherits:
-
Object
- Object
- Midnight::BusinessLogic::Event
- Defined in:
- lib/midnight/business_logic/event.rb
Defined Under Namespace
Classes: SchemaViolation
Constant Summary collapse
- DEFAULT_METADATA_GENERATOR =
lambda do { occurred_at: ::Time.current.iso8601(6) } end
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data: {}, metadata: nil) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(data: {}, metadata: nil) ⇒ Event
Returns a new instance of Event.
16 17 18 19 20 |
# File 'lib/midnight/business_logic/event.rb', line 16 def initialize(data: {}, metadata: nil) @data = data @metadata = || DEFAULT_METADATA_GENERATOR.call freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
22 23 24 |
# File 'lib/midnight/business_logic/event.rb', line 22 def data @data end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
22 23 24 |
# File 'lib/midnight/business_logic/event.rb', line 22 def @metadata end |
Class Method Details
.strict(data: {}, metadata: nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/midnight/business_logic/event.rb', line 25 def strict(data: {}, metadata: nil) ensure_schema(data) new( data: data, metadata: ) end |