Class: Cymometer::Helper::DSL
- Inherits:
-
Object
- Object
- Cymometer::Helper::DSL
- Defined in:
- lib/cymometer/helper.rb
Overview
3) DSL builder classes for configure_cymometer
Instance Method Summary collapse
- #counter(name, &block) ⇒ Object
-
#initialize(klass) ⇒ DSL
constructor
A new instance of DSL.
- #namespace(ns) ⇒ Object
- #redis(client) ⇒ Object
Constructor Details
#initialize(klass) ⇒ DSL
Returns a new instance of DSL.
101 102 103 |
# File 'lib/cymometer/helper.rb', line 101 def initialize(klass) @klass = klass end |
Instance Method Details
#counter(name, &block) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/cymometer/helper.rb', line 113 def counter(name, &block) conf = CounterConfig.new(name) conf.instance_eval(&block) if block # Merge into class's counters new_counters = @klass.cymometer_counters.dup new_counters[name.to_sym] = conf.to_h @klass.instance_variable_set(:@cymometer_counters, new_counters) end |
#namespace(ns) ⇒ Object
105 106 107 |
# File 'lib/cymometer/helper.rb', line 105 def namespace(ns) @klass.instance_variable_set(:@cymometer_namespace, ns) end |
#redis(client) ⇒ Object
109 110 111 |
# File 'lib/cymometer/helper.rb', line 109 def redis(client) @klass.instance_variable_set(:@cymometer_redis, client) end |