Sha256: cf6b676d8f9c85cf764b5a0496cb0bf6d1a32010197b05c3586bc9f54f65e936
Contents?: true
Size: 997 Bytes
Versions: 4
Compression:
Stored size: 997 Bytes
Contents
# frozen_string_literal: true require 'dry/plugins/config' require 'dry/plugins/dsl' module Dry module Plugins # Builds a `Module` containing all plug-ins for `host` class ModuleBuilder def initialize(plugins_module_name: Plugins.config.plugins_module_name) @plugins_module_name = plugins_module_name end # @return [Symbol] attr_reader :plugins_module_name # @param host [Module] # # @return [Module] # # @example # require 'dry/plugins/module_builder' # # class Host # end # # module_builder = Dry::Plugins::ModuleBuilder.new # module_builder.call(Host) #=> Host::Plugins def call(host) plugins = if host.const_defined?(plugins_module_name) host.const_get(plugins_module_name) else host.const_set(plugins_module_name, Module.new) end plugins end end end end
Version data entries
4 entries across 4 versions & 1 rubygems