Module: Cymometer::Helper
- Defined in:
- lib/cymometer/helper.rb
Defined Under Namespace
Modules: ClassMethods Classes: CounterConfig, DSL
Class Method Summary collapse
Instance Method Summary collapse
-
#counter(name) ⇒ Object
—————————————————— 2) Instance-level method to fetch a configured counter ——————————————————.
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/cymometer/helper.rb', line 5 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#counter(name) ⇒ Object
2) Instance-level method to fetch a configured counter
def perform
c = counter(:some_counter)
c.increment!
end
66 67 68 69 70 71 72 73 |
# File 'lib/cymometer/helper.rb', line 66 def counter(name) config = self.class.counter_config(name) raise "No Cymometer counter named #{name.inspect} in #{self.class}" unless config # Memoize per-instance so we only build once @__cymometer_counter_cache ||= {} @__cymometer_counter_cache[name.to_sym] ||= build_cymometer_counter(config) end |