Class: Mayu::EncryptedMarshal::AdditionalData

Inherits:
Data
  • Object
show all
Defined in:
lib/mayu/encrypted_marshal.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#issued_atObject (readonly)

Returns the value of attribute issued_at

Returns:

  • (Object)

    the current value of issued_at



22
23
24
# File 'lib/mayu/encrypted_marshal.rb', line 22

def issued_at
  @issued_at
end

#ttlObject (readonly)

Returns the value of attribute ttl

Returns:

  • (Object)

    the current value of ttl



22
23
24
# File 'lib/mayu/encrypted_marshal.rb', line 22

def ttl
  @ttl
end

Class Method Details

.create(ttl:, now: Time.now) ⇒ Object



24
# File 'lib/mayu/encrypted_marshal.rb', line 24

def self.create(ttl:, now: Time.now) = new(now.to_f, ttl)

.unpack(data) ⇒ Object



26
27
28
29
# File 'lib/mayu/encrypted_marshal.rb', line 26

def self.unpack(data)
  data.unpack("D S") => [issued_at, ttl]
  new(issued_at, ttl)
end

Instance Method Details

#expired?(now: Time.now) ⇒ Boolean

Returns:

  • (Boolean)


32
# File 'lib/mayu/encrypted_marshal.rb', line 32

def expired?(now: Time.now) = now > expires_at

#expires_atObject



33
# File 'lib/mayu/encrypted_marshal.rb', line 33

def expires_at = Time.at(issued_at + ttl)

#packObject



31
# File 'lib/mayu/encrypted_marshal.rb', line 31

def pack = [issued_at, ttl].pack("D S")