Module: Modesty::MetricMethods
- Included in:
- API
- Defined in:
- lib/modesty/metric.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #add_metric(metric) ⇒ Object
- #metrics_starting_with(name) ⇒ Object
- #new_metric(slug, parent = nil, options = {}) {|Metric::Builder.new(metric)| ... } ⇒ Object
-
#track!(name, *args) ⇒ Object
Tracking.
Instance Attribute Details
Instance Method Details
#add_metric(metric) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/modesty/metric.rb', line 21 def add_metric(metric) raise Metric::Error, <<-msg if self.metrics.include? metric.slug Metric #{metric.slug.inspect} already defined! msg self.metrics[metric.slug] = metric end |
#metrics_starting_with(name) ⇒ Object
17 18 19 |
# File 'lib/modesty/metric.rb', line 17 def metrics_starting_with(name) self.metrics.select{|k, v| k.to_s.starts_with?(name)} end |
#new_metric(slug, parent = nil, options = {}) {|Metric::Builder.new(metric)| ... } ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/modesty/metric.rb', line 28 def new_metric(slug, parent=nil, ={}, &block) if parent.is_a? Hash =parent else [:parent] = parent end metric = Metric.new(slug, ) yield Metric::Builder.new(metric) if block_given? add_metric(metric) metric end |