Sha256: bebb688022997696327ba34468627a9fa42b57d6fb7618bc7a8380d90d6b2fad

Contents?: true

Size: 1.27 KB

Versions: 10

Compression:

Stored size: 1.27 KB

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
rom-core-4.2.1 lib/rom/global.rb
rom-core-4.2.0 lib/rom/global.rb
rom-core-4.1.2 lib/rom/global.rb
rom-core-4.1.1 lib/rom/global.rb
rom-core-4.1.0 lib/rom/global.rb
rom-core-4.0.2 lib/rom/global.rb
rom-core-4.0.1 lib/rom/global.rb
rom-core-4.0.0 lib/rom/global.rb
rom-core-4.0.0.rc2 lib/rom/global.rb
rom-core-4.0.0.rc1 lib/rom/global.rb