Class: Para::Cache::Item
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Para::Cache::Item
- Defined in:
- app/models/para/cache/item.rb
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#expires_at ⇒ Object
From ActiveSupport::Cache::Store::Entry Seconds since the epoch when the entry will expire.
- #mismatched?(_version = nil) ⇒ Boolean
- #value ⇒ Object
- #value=(new_value) ⇒ Object
Instance Method Details
#expired? ⇒ Boolean
16 17 18 |
# File 'app/models/para/cache/item.rb', line 16 def expired? read_attribute(:expires_at).try(:past?) || false end |
#expires_at ⇒ Object
From ActiveSupport::Cache::Store::Entry Seconds since the epoch when the entry will expire.
26 27 28 |
# File 'app/models/para/cache/item.rb', line 26 def expires_at read_attribute(:expires_at).try(:to_f) end |
#mismatched?(_version = nil) ⇒ Boolean
20 21 22 |
# File 'app/models/para/cache/item.rb', line 20 def mismatched?(_version = nil) false end |
#value ⇒ Object
7 8 9 |
# File 'app/models/para/cache/item.rb', line 7 def value Marshal.load(::Base64.decode64(self[:value])) if self[:value].present? end |
#value=(new_value) ⇒ Object
11 12 13 14 |
# File 'app/models/para/cache/item.rb', line 11 def value=(new_value) @raw_value = new_value self[:value] = ::Base64.encode64(Marshal.dump(@raw_value)) end |