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)
21 22 23 |
# File 'lib/vanity/metric/base.rb', line 21 def playground @playground end |
Instance Method Details
#metric(name, &block) ⇒ Object
Defines a new metric, using the class Vanity::Metric.
24 25 26 27 28 29 30 |
# File 'lib/vanity/metric/base.rb', line 24 def metric(name, &block) raise "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
32 33 34 35 36 |
# File 'lib/vanity/metric/base.rb', line 32 def new_binding(playground, id) @playground = playground @metric_id = id binding end |