Class: Decidim::NewsletterEncryptor

Inherits:
AttributeEncryptor show all
Defined in:
lib/decidim/newsletter_encryptor.rb

Instance Attribute Summary

Attributes inherited from AttributeEncryptor

#hash_digest_class, #is_retry, #key_len, #secret, #secret_key_base

Class Method Summary collapse

Methods inherited from AttributeEncryptor

#decrypt, decrypt, #encrypt, encrypt, #initialize

Constructor Details

This class inherits a constructor from Decidim::AttributeEncryptor

Class Method Details

.cryptorObject



15
16
17
# File 'lib/decidim/newsletter_encryptor.rb', line 15

def self.cryptor
  @cryptor ||= new(secret: "sent_at")
end

.sent_at_decrypted(string_encrypted) ⇒ Object

Method to decrypt sent_at newsletter.



11
12
13
# File 'lib/decidim/newsletter_encryptor.rb', line 11

def self.sent_at_decrypted(string_encrypted)
  cryptor.decrypt(string_encrypted)
end

.sent_at_encrypted(user_id, sent_at) ⇒ Object

Method to create string encrypt using sent_at time to unsubscribe’s user



6
7
8
# File 'lib/decidim/newsletter_encryptor.rb', line 6

def self.sent_at_encrypted(user_id, sent_at)
  cryptor.encrypt("#{user_id}-#{sent_at.to_i}")
end