Sha256: aab5731651986cda3bfd15af9a5c8afc0a60089de6a8af4a2147ef865ca29e2a

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'rom/plugin_registry'
require 'rom/global/plugin_dsl'

module ROM
  # Globally accessible public interface exposed via ROM module
  #
  # @api public
  module Global
    # Set base global registries in ROM constant
    #
    # @api private
    def self.extended(rom)
      super

      rom.instance_variable_set('@adapters', {})
      rom.instance_variable_set('@plugin_registry', PluginRegistry.new)
    end

    # An internal adapter identifier => adapter module map used by setup
    #
    # @return [Hash<Symbol=>Module>]
    #
    # @api private
    attr_reader :adapters

    # An internal identifier => plugin map used by the setup
    #
    # @return [Hash]
    #
    # @api private
    attr_reader :plugin_registry

    # Global plugin setup DSL
    #
    # @example
    #   ROM.plugins do
    #     register :publisher, Plugin::Publisher, type: :command
    #   end
    #
    # @api public
    def plugins(*args, &block)
      PluginDSL.new(plugin_registry, *args, &block)
    end

    # Register adapter namespace under a specified identifier
    #
    # @param [Symbol] identifier
    # @param [Class,Module] adapter
    #
    # @return [self]
    #
    # @api private
    def register_adapter(identifier, adapter)
      adapters[identifier] = adapter
      self
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rom-core-5.3.2 lib/rom/global.rb
rom-core-5.3.1 lib/rom/global.rb
rom-core-5.3.0 lib/rom/global.rb
rom-core-5.2.6 lib/rom/global.rb
rom-core-5.2.5 lib/rom/global.rb
rom-core-5.2.4 lib/rom/global.rb
rom-core-5.2.3 lib/rom/global.rb
rom-core-5.2.2 lib/rom/global.rb
rom-core-5.2.1 lib/rom/global.rb
rom-core-5.1.2 lib/rom/global.rb
rom-core-5.1.1 lib/rom/global.rb
rom-core-5.1.0 lib/rom/global.rb
rom-core-5.0.2 lib/rom/global.rb
rom-core-5.0.1 lib/rom/global.rb
rom-core-5.0.0 lib/rom/global.rb