Permalink
Cannot retrieve contributors at this time
58 lines (52 sloc)
1.27 KB
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# | |
# @example | |
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 |