diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-07-11 12:15:08 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-07-11 12:15:08 -0700 |
commit | 6f0de6b1420f2c256f536c6eadadf23888164193 (patch) | |
tree | bb789a16687fdfa9abf2f4c7dedf78199c88c875 /acceptance | |
parent | 1d471dcedeaa694e24d1c89ed13e2ba750694575 (diff) | |
download | chef-6f0de6b1420f2c256f536c6eadadf23888164193.tar.gz |
fix some issues with sinatra app
i'm not certain how this ever worked, odd.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'acceptance')
-rw-r--r-- | acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb b/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb index 3fb2c730b0..fcfc704d29 100644 --- a/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb +++ b/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb @@ -17,35 +17,51 @@ module ApiHelpers end class Counter - def self.reset - @@counters = Hash.new { |h, k| h[k] = 0 } - end + class << self + attr_accessor :counters - def self.increment(payload) - counter_name = ApiHelpers.payload_type(payload) - @@counters[counter_name] += 1 - end + def counters + @counters ||= Hash.new { |h, k| h[k] = 0 } + end + + def reset + @counters = nil + end + + def increment(payload) + counter_name = ApiHelpers.payload_type(payload) + counters[counter_name] += 1 + end - def self.to_json - @@counters.to_json + def to_json + counters.to_json + end end end class MessageCache include ApiHelpers - def self.reset - @@message_cache = {} - end + class << self + attr_accessor :message_cache - def self.store(payload) - cache_key = ApiHelpers.payload_type(payload) + def message_cache + @message_cache ||= {} + end - @@message_cache[cache_key] = payload - end + def reset + @message_cache = nil + end + + def store(payload) + cache_key = ApiHelpers.payload_type(payload) + + message_cache[cache_key] = payload + end - def self.fetch(cache_key) - @@message_cache[cache_key].to_json + def fetch(cache_key) + message_cache[cache_key].to_json + end end end |