Class: Rack::Sparklines::Handlers::AbstractData
- Inherits:
-
Object
- Object
- Rack::Sparklines::Handlers::AbstractData
- Defined in:
- lib/rack-sparklines/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.
8 9 10 |
# File 'lib/rack-sparklines/handlers/abstract_data.rb', line 8 def data_path @data_path end |
Instance Method Details
#already_cached?(cacher) ⇒ Boolean
18 19 20 21 22 |
# File 'lib/rack-sparklines/handlers/abstract_data.rb', line 18 def already_cached?(cacher) if cache_time = cacher.exists? && cacher.updated_at cache_time > updated_at end end |
#exists? ⇒ Boolean
24 25 26 |
# File 'lib/rack-sparklines/handlers/abstract_data.rb', line 24 def exists? false end |
#fetch ⇒ Object
Yield an array of numbers for sparkline datapoints.
33 34 35 |
# File 'lib/rack-sparklines/handlers/abstract_data.rb', line 33 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).
12 13 14 15 16 |
# File 'lib/rack-sparklines/handlers/abstract_data.rb', line 12 def set(data_path) data = dup data.data_path = data_path data end |
#updated_at ⇒ Object
28 29 30 |
# File 'lib/rack-sparklines/handlers/abstract_data.rb', line 28 def updated_at raise NotImplementedError end |