Sha256: 4220ee2685da7e221ad9bad90562cc8c6ce731d1ea3ce67f2e88d02537024137

Contents?: true

Size: 863 Bytes

Versions: 53

Compression:

Stored size: 863 Bytes

Contents

# frozen_string_literal: true

module ActionText
  module Encryption
    def encrypt
      transaction do
        super
        encrypt_rich_texts if has_encrypted_rich_texts?
      end
    end

    def decrypt
      transaction do
        super
        decrypt_rich_texts if has_encrypted_rich_texts?
      end
    end

    private
      def encrypt_rich_texts
        encryptable_rich_texts.each(&:encrypt)
      end

      def decrypt_rich_texts
        encryptable_rich_texts.each(&:decrypt)
      end

      def has_encrypted_rich_texts?
        encryptable_rich_texts.present?
      end

      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
  end
end

Version data entries

53 entries across 50 versions & 5 rubygems

Version Path
actiontext-7.1.5 lib/action_text/encryption.rb
actiontext-7.1.4.2 lib/action_text/encryption.rb
actiontext-7.0.8.6 lib/action_text/encryption.rb
actiontext-7.1.4.1 lib/action_text/encryption.rb
actiontext-7.0.8.5 lib/action_text/encryption.rb
actiontext-7.1.4 lib/action_text/encryption.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actiontext-7.1.3.4/lib/action_text/encryption.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.8.4/lib/action_text/encryption.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/actiontext-7.0.5.1/lib/action_text/encryption.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/actiontext-7.0.5.1/lib/action_text/encryption.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/actiontext-7.0.5.1/lib/action_text/encryption.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actiontext-7.1.3.4/lib/action_text/encryption.rb
actiontext-7.1.3.4 lib/action_text/encryption.rb
actiontext-7.0.8.4 lib/action_text/encryption.rb
actiontext-7.1.3.2 lib/action_text/encryption.rb
actiontext-7.1.3.1 lib/action_text/encryption.rb
actiontext-7.0.8.1 lib/action_text/encryption.rb
actiontext-7.1.3 lib/action_text/encryption.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actiontext-7.0.2.3/lib/action_text/encryption.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actiontext-7.0.3.1/lib/action_text/encryption.rb