123456789_123456789_123456789_123456789_123456789_

Module: ActionText::Encryption

Relationships & Source Files
Defined in: actiontext/lib/action_text/encryption.rb

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#has_encrypted_rich_texts?Boolean (readonly, private)

[ GitHub ]

  
# File 'actiontext/lib/action_text/encryption.rb', line 28

def has_encrypted_rich_texts?
  encryptable_rich_texts.present?
end

Instance Method Details

#decrypt

[ GitHub ]

  
# File 'actiontext/lib/action_text/encryption.rb', line 12

def decrypt
  transaction do
    super
    decrypt_rich_texts if has_encrypted_rich_texts?
  end
end

#decrypt_rich_texts (private)

[ GitHub ]

  
# File 'actiontext/lib/action_text/encryption.rb', line 24

def decrypt_rich_texts
  encryptable_rich_texts.each(&:decrypt)
end

#encrypt

[ GitHub ]

  
# File 'actiontext/lib/action_text/encryption.rb', line 5

def encrypt
  transaction do
    super
    encrypt_rich_texts if has_encrypted_rich_texts?
  end
end

#encrypt_rich_texts (private)

[ GitHub ]

  
# File 'actiontext/lib/action_text/encryption.rb', line 20

def encrypt_rich_texts
  encryptable_rich_texts.each(&:encrypt)
end

#encryptable_rich_texts (private)

[ GitHub ]

  
# File 'actiontext/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