Module: Vanity::Metric::Definition
- Defined in:
- lib/vanity/metric/base.rb
Overview
These methods are available when defining a metric in a file loaded from the experiments/metrics
directory.
For example:
$ cat experiments/metrics/yawn_sec
metric "Yawns/sec" do
description "Most boring metric ever"
end
Instance Attribute Summary collapse
- #playground ⇒ Object readonly
Instance Method Summary collapse
-
#metric(name, &block) ⇒ Object
Defines a new metric, using the class Vanity::Metric.
- #new_binding(playground, id) ⇒ Object
Instance Attribute Details
#playground ⇒ Object (readonly)
24 25 26 |
# File 'lib/vanity/metric/base.rb', line 24 def playground @playground end |
Instance Method Details
#metric(name, &block) ⇒ Object
Defines a new metric, using the class Vanity::Metric.
27 28 29 30 31 32 |
# File 'lib/vanity/metric/base.rb', line 27 def metric(name, &block) fail "Metric #{@metric_id} already defined in playground" if playground.metrics[@metric_id] metric = Metric.new(playground, name.to_s, @metric_id) metric.instance_eval &block playground.metrics[@metric_id] = metric end |
#new_binding(playground, id) ⇒ Object
34 35 36 37 |
# File 'lib/vanity/metric/base.rb', line 34 def new_binding(playground, id) @playground, @metric_id = playground, id binding end |