Module: Staccato::Measurable
- Included in:
- Staccato::Measurement::Checkout, Staccato::Measurement::CheckoutOption, Staccato::Measurement::ImpressionList, Staccato::Measurement::Product, Staccato::Measurement::ProductImpression, Staccato::Measurement::Promotion, Staccato::Measurement::Transaction
- Defined in:
- lib/staccato/measurable.rb
Overview
Measurable adds field mapping and param collection
for Measurement classes to be add to Hit
Class Method Summary collapse
Instance Method Summary collapse
-
#fields ⇒ Object
fields from options for this measurement.
- #initialize(options = {}) ⇒ Object
-
#params ⇒ Hash
collects the parameters from options for this measurement.
-
#prefix ⇒ String
measurement option prefix.
Class Method Details
.included(model) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/staccato/measurable.rb', line 5 def self.included(model) model.extend Forwardable model.class_eval do attr_accessor :options def_delegators :@options, *model::FIELDS.keys end end |
Instance Method Details
#fields ⇒ Object
fields from options for this measurement
21 22 23 |
# File 'lib/staccato/measurable.rb', line 21 def fields self.class::FIELDS end |
#initialize(options = {}) ⇒ Object
16 17 18 |
# File 'lib/staccato/measurable.rb', line 16 def initialize( = {}) self. = OptionSet.new() end |
#params ⇒ Hash
collects the parameters from options for this measurement
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/staccato/measurable.rb', line 33 def params Hash[ fields.map { |field,key| next if key.nil? key = (prefix+key.to_s) [key, [field]] unless [field].nil? }.compact ] end |
#prefix ⇒ String
measurement option prefix
27 28 29 |
# File 'lib/staccato/measurable.rb', line 27 def prefix '' end |