module ActionText::Encryption

Public Instance Methods

decrypt() click to toggle source
Calls superclass method
# File lib/action_text/encryption.rb, line 12
def decrypt
  transaction do
    super
    decrypt_rich_texts if has_encrypted_rich_texts?
  end
end
encrypt() click to toggle source
Calls superclass method
# File lib/action_text/encryption.rb, line 5
def encrypt
  transaction do
    super
    encrypt_rich_texts if has_encrypted_rich_texts?
  end
end

Private Instance Methods

decrypt_rich_texts() click to toggle source
# File lib/action_text/encryption.rb, line 24
def decrypt_rich_texts
  encryptable_rich_texts.each(&:decrypt)
end
encrypt_rich_texts() click to toggle source
# File lib/action_text/encryption.rb, line 20
def encrypt_rich_texts
  encryptable_rich_texts.each(&:encrypt)
end
encryptable_rich_texts() click to toggle source
# File lib/action_text/encryption.rb, line 32
def encryptable_rich_texts
  @encryptable_rich_texts ||= self.class.rich_text_association_names
    .filter_map { |attribute_name| send(attribute_name) }
    .find_all { |record| record.is_a?(ActionText::EncryptedRichText) }
end
has_encrypted_rich_texts?() click to toggle source
# File lib/action_text/encryption.rb, line 28
def has_encrypted_rich_texts?
  encryptable_rich_texts.present?
end