Class: TrackRelay::DSL::ParamBuilder
- Inherits:
-
Object
- Object
- TrackRelay::DSL::ParamBuilder
- Defined in:
- lib/track_relay/dsl/param_builder.rb
Overview
The DSL receiver for the body of ‘event :name do … end`.
Each type method (‘integer`, `string`, `float`, `boolean`, `datetime`) records a EventDefinition::ParamSchema keyed by param name. `user_property` accumulates user-property declarations separately so they can be passed through to the resulting EventDefinition without polluting `params`.
ParamBuilder does NOT validate or register anything itself — that is EventBuilder‘s job. Keeping the builder side-effect-free makes it trivial to test and lets EventBuilder run validation against the complete definition (so e.g. param-count overflow is reported with the full param set).
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#user_properties ⇒ Object
readonly
Returns the value of attribute user_properties.
Instance Method Summary collapse
- #boolean(name, **opts) ⇒ Object
- #datetime(name, **opts) ⇒ Object
- #float(name, **opts) ⇒ Object
-
#initialize(event_name) ⇒ ParamBuilder
constructor
A new instance of ParamBuilder.
- #integer(name, **opts) ⇒ EventDefinition::ParamSchema
- #string(name, **opts) ⇒ Object
-
#user_property(name, type) ⇒ Object
Declare a user property on the surrounding event.
Constructor Details
#initialize(event_name) ⇒ ParamBuilder
Returns a new instance of ParamBuilder.
25 26 27 28 29 |
# File 'lib/track_relay/dsl/param_builder.rb', line 25 def initialize(event_name) @event_name = event_name @params = {} @user_properties = {} end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
21 22 23 |
# File 'lib/track_relay/dsl/param_builder.rb', line 21 def params @params end |
#user_properties ⇒ Object (readonly)
Returns the value of attribute user_properties.
21 22 23 |
# File 'lib/track_relay/dsl/param_builder.rb', line 21 def user_properties @user_properties end |
Instance Method Details
#boolean(name, **opts) ⇒ Object
47 48 49 |
# File 'lib/track_relay/dsl/param_builder.rb', line 47 def boolean(name, **opts) record_param(name, :boolean, opts) end |
#datetime(name, **opts) ⇒ Object
51 52 53 |
# File 'lib/track_relay/dsl/param_builder.rb', line 51 def datetime(name, **opts) record_param(name, :datetime, opts) end |
#float(name, **opts) ⇒ Object
43 44 45 |
# File 'lib/track_relay/dsl/param_builder.rb', line 43 def float(name, **opts) record_param(name, :float, opts) end |
#integer(name, **opts) ⇒ EventDefinition::ParamSchema
35 36 37 |
# File 'lib/track_relay/dsl/param_builder.rb', line 35 def integer(name, **opts) record_param(name, :integer, opts) end |
#string(name, **opts) ⇒ Object
39 40 41 |
# File 'lib/track_relay/dsl/param_builder.rb', line 39 def string(name, **opts) record_param(name, :string, opts) end |
#user_property(name, type) ⇒ Object
Declare a user property on the surrounding event. Accumulated separately from regular params so EventDefinition can keep them in ‘user_properties`.
62 63 64 |
# File 'lib/track_relay/dsl/param_builder.rb', line 62 def user_property(name, type) @user_properties[name] = type end |