Class: Modesty::Metric::Builder
- Inherits:
-
Object
- Object
- Modesty::Metric::Builder
- Defined in:
- lib/modesty/metric/builder.rb
Instance Method Summary collapse
-
#initialize(metric) ⇒ Builder
constructor
A new instance of Builder.
- #method_missing(name, *args) ⇒ Object
- #submetric(slug, &blk) ⇒ Object
Constructor Details
#initialize(metric) ⇒ Builder
Returns a new instance of Builder.
13 14 15 |
# File 'lib/modesty/metric/builder.rb', line 13 def initialize(metric) @metric = metric end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/modesty/metric/builder.rb', line 5 def method_missing(name, *args) if Metric::ATTRIBUTES.include? name @metric.instance_variable_set("@#{name}", args[0]) else super end end |
Instance Method Details
#submetric(slug, &blk) ⇒ Object
17 18 19 |
# File 'lib/modesty/metric/builder.rb', line 17 def submetric(slug, &blk) Modesty.new_metric(@metric.slug/slug, @metric, &blk) end |