Sha256: d440bceb2d5a6b2c43c8677aa5faa95db729fb4a7ad65479cc8142106762d0b0

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true
#
# Why the funky filename
# (lib/active_record/connection_adapters/postgres_cipherstash_adapter.rb)
# that doesn't match the gem structure? It's to hook into Rails.
#
# See this chunk from:
# https://github.com/rails/rails/blob/d7d93faacfe0ca3297a47f676772828d7210b9bc/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb#L325-L330
#
#   # Require the adapter itself and give useful feedback about
#   #   1. Missing adapter gems and
#   #   2. Adapter gems' missing dependencies.
#   path_to_adapter = "active_record/connection_adapters/#{db_config.adapter}_adapter"
#   begin
#     require path_to_adapter
#   ...
# This is the entrypoint that is called when Rails looks for the adapter,
# when you have this in your database.yml config:
#
#   adapter: postgres_cipherstash
#
# See: https://github.com/rails/rails/blob/d7d93faacfe0ca3297a47f676772828d7210b9bc/activerecord/lib/active_record/database_configurations/database_config.rb#L16-L18
#
#
# ... to match the implicit AR naming scheme enforced by "rails dbconsole", eg.
# https://github.com/rails/rails/blob/7-0-stable/railties/lib/rails/commands/dbconsole/dbconsole_command.rb#L46
#
#
# Depending on the version of Rails being used, the relevant child postgres_cipherstash_adapter module is required.


require "cipherstash-pg"

case Rails::VERSION::MAJOR
when 7
  require "active_record/connection_adapters/7.0/postgres_cipherstash_adapter"
when 6
  require "active_record/connection_adapters/6.1/postgres_cipherstash_adapter"
else
  STDERR.puts "CipherStash only supports Rails versions 6.x and 7.x"
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.6.0 lib/active_record/connection_adapters/postgres_cipherstash_adapter.rb