Class: Para::Cache::Item

Inherits:
ApplicationRecord show all
Defined in:
app/models/para/cache/item.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

with_belongs_to_optional_option_if_needed

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/models/para/cache/item.rb', line 16

def expired?
  read_attribute(:expires_at).try(:past?) || false
end

#expires_atObject

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

Returns:

  • (Boolean)


20
21
22
# File 'app/models/para/cache/item.rb', line 20

def mismatched?(_version = nil)
  false
end

#valueObject



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