Class: Reacto::Cache::File
- Inherits:
-
Object
- Object
- Reacto::Cache::File
- Defined in:
- lib/reacto/cache/file.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #closed? ⇒ Boolean
- #each ⇒ Object
- #error ⇒ Object
- #error? ⇒ Boolean
-
#initialize(location: nil, ttl: 60) ⇒ File
constructor
A new instance of File.
- #on_close ⇒ Object
- #on_error(error) ⇒ Object
- #on_value(value) ⇒ Object
- #ready? ⇒ Boolean
Constructor Details
#initialize(location: nil, ttl: 60) ⇒ File
Returns a new instance of File.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/reacto/cache/file.rb', line 10 def initialize(location: nil, ttl: 60) @location = location @ttl = ttl if @location.nil? fail( ArgumentError, 'File location is mandatory while using file cache!' ) end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/reacto/cache/file.rb', line 8 def data @data end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
7 8 9 |
# File 'lib/reacto/cache/file.rb', line 7 def location @location end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
7 8 9 |
# File 'lib/reacto/cache/file.rb', line 7 def ttl @ttl end |
Instance Method Details
#closed? ⇒ Boolean
43 44 45 46 47 48 |
# File 'lib/reacto/cache/file.rb', line 43 def closed? return false unless ready? deserialize data.closed? end |
#each ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/reacto/cache/file.rb', line 27 def each return unless ready? deserialize data.each do |value| yield value end end |
#error ⇒ Object
50 51 52 53 54 55 |
# File 'lib/reacto/cache/file.rb', line 50 def error return false unless ready? deserialize data.error end |
#error? ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/reacto/cache/file.rb', line 36 def error? return false unless ready? deserialize data.error? end |
#on_close ⇒ Object
70 71 72 73 74 75 |
# File 'lib/reacto/cache/file.rb', line 70 def on_close init_data data.on_close serialize end |
#on_error(error) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/reacto/cache/file.rb', line 63 def on_error(error) init_data data.on_error(error) serialize end |
#on_value(value) ⇒ Object
57 58 59 60 61 |
# File 'lib/reacto/cache/file.rb', line 57 def on_value(value) init_data data.on_value(value) end |
#ready? ⇒ Boolean
21 22 23 24 25 |
# File 'lib/reacto/cache/file.rb', line 21 def ready? return data.ready? unless data.nil? fresh? end |