Sha256: 9311c2d90ccd549fb7fff75e653e586699df7dbecb07314505a0c279425b889b

Contents?: true

Size: 654 Bytes

Versions: 2

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

module Aikotoba
  module TokenEncryptable
    extend ActiveSupport::Concern

    included do
      if enabled_aikotoba_enctypted_token?
        if available_active_record_encryption?
          encrypts :token, deterministic: true
        else
          raise Errors::NotAvailableException, "You need to be able to encrypt the token using Active Record Encryption."
        end
      end
    end

    module ClassMethods
      def enabled_aikotoba_enctypted_token?
        Aikotoba.encypted_token
      end

      def available_active_record_encryption?
        ActiveRecord::VERSION::MAJOR >= 7
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aikotoba-0.1.1 app/models/concerns/aikotoba/token_encryptable.rb
aikotoba-0.1.0 app/models/concerns/aikotoba/token_encryptable.rb