Class: Nightfury::Metric::Base
- Inherits:
-
Object
- Object
- Nightfury::Metric::Base
- Defined in:
- lib/nightfury/metric.rb
Direct Known Subclasses
Constant Summary collapse
- ALLOWED_STEPS =
[:minute, :hour, :day, :week, :month]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
-
#redis_key_prefix ⇒ Object
readonly
Returns the value of attribute redis_key_prefix.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
-
#store_as ⇒ Object
readonly
Returns the value of attribute store_as.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(name, options = {}) ⇒ Base
constructor
A new instance of Base.
- #redis_key ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Base
9 10 11 12 13 14 15 |
# File 'lib/nightfury/metric.rb', line 9 def initialize(name, ={}) @name = name @redis = Nightfury.redis @redis_key_prefix = [:redis_key_prefix] @store_as = [:store_as] @step = ALLOWED_STEPS.include?([:step]) ? [:step] : :minute end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/nightfury/metric.rb', line 7 def name @name end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
7 8 9 |
# File 'lib/nightfury/metric.rb', line 7 def redis @redis end |
#redis_key_prefix ⇒ Object (readonly)
Returns the value of attribute redis_key_prefix.
7 8 9 |
# File 'lib/nightfury/metric.rb', line 7 def redis_key_prefix @redis_key_prefix end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
7 8 9 |
# File 'lib/nightfury/metric.rb', line 7 def step @step end |
#store_as ⇒ Object (readonly)
Returns the value of attribute store_as.
7 8 9 |
# File 'lib/nightfury/metric.rb', line 7 def store_as @store_as end |
Instance Method Details
#delete ⇒ Object
23 24 25 |
# File 'lib/nightfury/metric.rb', line 23 def delete redis.del redis_key end |
#redis_key ⇒ Object
17 18 19 20 21 |
# File 'lib/nightfury/metric.rb', line 17 def redis_key prefix = redis_key_prefix.blank? ? '' : "#{redis_key_prefix}:" store_name = store_as ? store_as : name "#{prefix}#{store_name}" end |