Class: TrackRelay::EventDefinition
- Inherits:
-
Object
- Object
- TrackRelay::EventDefinition
- Defined in:
- lib/track_relay/event_definition.rb
Overview
Catalog metadata for a single event.
An EventDefinition is the immutable description of an event as declared in ‘TrackRelay.catalog do … end`. It holds the event name, the schema of every declared param (a Hash of ParamSchema keyed by param name), and any user_property declarations.
EventDefinition is paired with EventPayload at runtime: the definition is the schema, the payload is the data, and ‘payload.validate!` checks the data against the schema.
Instances are deep-frozen at construction so the catalog cannot be mutated after load. Re-defining an event requires Catalog.clear!.
Defined Under Namespace
Classes: ParamSchema
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#user_properties ⇒ Object
readonly
Returns the value of attribute user_properties.
Instance Method Summary collapse
-
#initialize(name:, params: {}, user_properties: {}) ⇒ EventDefinition
constructor
A new instance of EventDefinition.
Constructor Details
#initialize(name:, params: {}, user_properties: {}) ⇒ EventDefinition
Returns a new instance of EventDefinition.
67 68 69 70 71 72 |
# File 'lib/track_relay/event_definition.rb', line 67 def initialize(name:, params: {}, user_properties: {}) @name = name @params = params.freeze @user_properties = user_properties.freeze freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
61 62 63 |
# File 'lib/track_relay/event_definition.rb', line 61 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
61 62 63 |
# File 'lib/track_relay/event_definition.rb', line 61 def params @params end |
#user_properties ⇒ Object (readonly)
Returns the value of attribute user_properties.
61 62 63 |
# File 'lib/track_relay/event_definition.rb', line 61 def user_properties @user_properties end |