Module: Cymometer::Helper::ClassMethods

Defined in:
lib/cymometer/helper.rb

Overview


1) Class-level methods


Instance Method Summary collapse

Instance Method Details

#configure_cymometer(&block) ⇒ Object

DSL entrypoint

configure_cymometer do
  namespace "my_namespace"
  redis MyCustomRedis

  counter :some_counter do
    limit 10
    window 60
    key { "dynamic_key_for_#{self.object_id}" }
  end
end


27
28
29
# File 'lib/cymometer/helper.rb', line 27

def configure_cymometer(&block)
  DSL.new(self).instance_eval(&block)
end

#counter_config(name) ⇒ Object

Retrieve the stored counter config (hash) by name



52
53
54
# File 'lib/cymometer/helper.rb', line 52

def counter_config(name)
  cymometer_counters[name.to_sym]
end

#cymometer_countersObject

Access the counters hash



34
35
36
# File 'lib/cymometer/helper.rb', line 34

def cymometer_counters
  @cymometer_counters ||= {}
end

#cymometer_namespaceObject

Accessors for the optional shared namespace & redis client



41
42
43
# File 'lib/cymometer/helper.rb', line 41

def cymometer_namespace
  @cymometer_namespace
end

#cymometer_redisObject



45
46
47
# File 'lib/cymometer/helper.rb', line 45

def cymometer_redis
  @cymometer_redis
end