Sha256: 0a896edd171da401dc938fcf8a788b1fa7ce43d70d7796d7f5a2edfcf7911053

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'

module Dry
  module Plugins
    # Plug-ins DSL
    module DSL
      # @api private
      def self.extended(plugins)
        super(plugins)
        plugins.extend SingleForwardable
        plugins.def_single_delegators Plugins.config.registry_method,
                                      :register,
                                      :resolve,
                                      :[]
      end

      # @return [Module, Host::DSL]
      def host
        @host ||= Inflecto.constantize(name.gsub(/::[^:]+$/, ''))
      end

      # @!method register(name, plugin)
      #   @param name [#to_sym]
      #   @param plugin [Module, Plugin]
      #
      #   @return [Plugin]
      #
      #   @see Dry::Plugins::Registry#register

      # @!method resolve(name)
      #   @param name [#to_sym]
      #
      #   @return [Plugin]
      #
      #   @see Dry::Plugins::Registry#resolve
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-plugins-0.1.0 lib/dry/plugins/dsl.rb