Class: Sparkplug::Handlers::AbstractData
- Inherits:
-
Object
- Object
- Sparkplug::Handlers::AbstractData
- Defined in:
- lib/sparkplug/handlers/abstract_data.rb
Overview
Abstract class for retrieving the data and determining whether the cache needs to be refreshed.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_path ⇒ Object
Returns the value of attribute data_path.
Instance Method Summary collapse
- #already_cached?(cacher) ⇒ Boolean
- #exists? ⇒ Boolean
-
#fetch ⇒ Object
Yield an array of numbers for sparkline datapoints.
-
#set(data_path) ⇒ Object
Setting the data_path returns a duplicate of this object that has any custom instance variables (configuration settings, for example).
- #updated_at ⇒ Object
Instance Attribute Details
#data_path ⇒ Object
Returns the value of attribute data_path.
6 7 8 |
# File 'lib/sparkplug/handlers/abstract_data.rb', line 6 def data_path @data_path end |
Instance Method Details
#already_cached?(cacher) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/sparkplug/handlers/abstract_data.rb', line 16 def already_cached?(cacher) if cache_time = cacher.exists? && cacher.updated_at cache_time > updated_at end end |
#exists? ⇒ Boolean
22 23 24 |
# File 'lib/sparkplug/handlers/abstract_data.rb', line 22 def exists? false end |
#fetch ⇒ Object
Yield an array of numbers for sparkline datapoints.
31 32 33 |
# File 'lib/sparkplug/handlers/abstract_data.rb', line 31 def fetch raise NotImplementedError end |
#set(data_path) ⇒ Object
Setting the data_path returns a duplicate of this object that has any custom instance variables (configuration settings, for example).
10 11 12 13 14 |
# File 'lib/sparkplug/handlers/abstract_data.rb', line 10 def set(data_path) data = dup data.data_path = data_path data end |
#updated_at ⇒ Object
26 27 28 |
# File 'lib/sparkplug/handlers/abstract_data.rb', line 26 def updated_at raise NotImplementedError end |