nightfury 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/nightfury/identity.rb +3 -3
- data/lib/nightfury/version.rb +1 -1
- data/spec/nightfury/identity_spec.rb +2 -1
- metadata +1 -1
data/lib/nightfury/identity.rb
CHANGED
@@ -17,13 +17,13 @@ module Nightfury
|
|
17
17
|
self.to_s.demodulize.underscore
|
18
18
|
end
|
19
19
|
|
20
|
-
def metric(name, type = :value)
|
20
|
+
def metric(name, type = :value, options={})
|
21
21
|
@metrics ||= {}
|
22
22
|
@metrics[name] = {type: type}
|
23
|
-
|
23
|
+
store_as = options[:store_as] ? ":#{options[:store_as]}" : 'nil'
|
24
24
|
class_eval <<-ENDOFMETHOD
|
25
25
|
def #{name}
|
26
|
-
@_#{name} ||= METRIC_MAPPINGS[:#{type}].new(:#{name}, redis_key_prefix: key_prefix)
|
26
|
+
@_#{name} ||= METRIC_MAPPINGS[:#{type}].new(:#{name}, redis_key_prefix: key_prefix, store_as: #{store_as})
|
27
27
|
end
|
28
28
|
ENDOFMETHOD
|
29
29
|
end
|
data/lib/nightfury/version.rb
CHANGED
@@ -63,12 +63,13 @@ describe Nightfury::Identity::Base do
|
|
63
63
|
|
64
64
|
describe "Dynamically generated metric" do
|
65
65
|
it "should instantiate the right metric class" do
|
66
|
-
Dummy.metric(:third_count)
|
66
|
+
Dummy.metric(:third_count, :value, store_as: :t)
|
67
67
|
d = Dummy.new(1)
|
68
68
|
metric_object = d.third_count
|
69
69
|
metric_object.should be_kind_of(Nightfury::Metric::Value)
|
70
70
|
metric_object.name.should == :third_count
|
71
71
|
metric_object.redis_key_prefix.should == 'dummy.1'
|
72
|
+
metric_object.store_as.should == :t
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|