Sha256: 6e68339e52251047e716957ec849629d0358c1884add7f3e6d717c550f73dda5

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

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

      # @!method plugins_registry
      #   @return [Registry]
      #
      #   @see Config#registry_method
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-plugins-0.4.0 lib/dry/plugins/dsl.rb
dry-plugins-0.3.0 lib/dry/plugins/dsl.rb
dry-plugins-0.2.0 lib/dry/plugins/dsl.rb