Class: SpeedupDashboard::RequestStore
- Inherits:
-
Object
- Object
- SpeedupDashboard::RequestStore
- Defined in:
- lib/speedup-dashboard/request_store.rb
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(request_id) ⇒ RequestStore
constructor
A new instance of RequestStore.
- #load(contexts, data) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(request_id) ⇒ RequestStore
Returns a new instance of RequestStore.
36 37 38 |
# File 'lib/speedup-dashboard/request_store.rb', line 36 def initialize(request_id) @request_id = request_id end |
Class Method Details
.connection ⇒ Object
32 33 34 |
# File 'lib/speedup-dashboard/request_store.rb', line 32 def self.connection @connection || establish_connection(Rails.configuration.speedup_dashboard.adapter) end |
.establish_connection(adapter_options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/speedup-dashboard/request_store.rb', line 7 def self.establish_connection() adapter, *parameters = *Array.wrap().flatten @connection = case adapter when Symbol adapter_class_name = adapter.to_s.camelize adapter_class = begin require "speedup/adapters/#{adapter}" rescue LoadError => e raise "Could not find adapter for #{adapter} (#{e})" else ::Speedup::Adapters.const_get(adapter_class_name) end adapter_class.new(*parameters) when nil require 'speedup/adapters/memory' ::Speedup::Adapters::Memory.new else adapter end @connection end |
Instance Method Details
#id ⇒ Object
40 41 42 |
# File 'lib/speedup-dashboard/request_store.rb', line 40 def id @request_id end |
#load(contexts, data) ⇒ Object
44 45 46 |
# File 'lib/speedup-dashboard/request_store.rb', line 44 def load(contexts, data) @data = Speedup::RequestData.new.load(contexts, data) end |
#save ⇒ Object
48 49 50 |
# File 'lib/speedup-dashboard/request_store.rb', line 48 def save self.class.connection.write(@request_id, @data) end |