Sha256: 7f014ced3ddcba881bee064201a7b5e86d93384cc8b0f0181288720f53fd1b35

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

module ROM
  module Plugins
    # @api public
    module ClassMethods
      # Include a registered plugin in this relation class
      #
      # @param [Symbol] plugin
      # @param [Hash] options
      # @option options [Symbol] :adapter (:default) first adapter to check for plugin
      #
      # @api public
      def use(name, **options)
        plugin = plugins[name].configure(**options).enable(self).apply
        component_config.plugins << plugin
        self
      end

      # Return all available plugins for the component type
      #
      # @api public
      def plugins
        @plugins ||= ROM.plugins[component_config.type].adapter(component_config.adapter)
      end

      private

      # Return component configuration
      #
      # @api private
      def component_config
        @component_config ||= config.key?(:component) ? config.component : config
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-6.0.0.alpha1 lib/rom/plugins/class_methods.rb