Sha256: 4dbd24eb4ee4ebc7748143bc9d784b00b479bad9fc6189859f677c415bd13fc4

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require "dry/configurable"

module Hanami
  module Providers
    class DB < Hanami::Provider::Source
      # @api public
      # @since 2.2.0
      class Adapter
        include Dry::Configurable

        # @api public
        # @since 2.2.0
        setting :plugins, mutable: true

        # @api private
        def initialize(...)
          @skip_defaults = Hash.new(false)
        end

        # @api public
        # @since 2.2.0
        def skip_defaults(setting_name = nil)
          @skip_defaults[setting_name] = true
        end

        # @api private
        private def skip_defaults?(setting_name = nil)
          @skip_defaults[setting_name]
        end

        # @api private
        def configure_from_adapter(other_adapter)
          return if skip_defaults?

          plugins.concat(other_adapter.plugins).uniq! unless skip_defaults?(:plugins)
        end

        # @api private
        def configure_for_database(database_url)
        end

        # @api public
        # @since 2.2.0
        def plugin(**plugin_spec, &config_block)
          plugins << [plugin_spec, config_block]
        end

        # @api public
        # @since 2.2.0
        def plugins
          config.plugins ||= []
        end

        # @api private
        def gateway_cache_keys
          gateway_options
        end

        # @api private
        def gateway_options
          {}
        end

        # @api public
        # @since 2.2.0
        def clear
          config.plugins = nil
          self
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-2.2.1 lib/hanami/providers/db/adapter.rb
hanami-2.2.0 lib/hanami/providers/db/adapter.rb
hanami-2.2.0.rc1 lib/hanami/providers/db/adapter.rb
hanami-2.2.0.beta2 lib/hanami/providers/db/adapter.rb