Sha256: 2dca6dcb2a48f9753f6c3bbb49d72a81e136eb172dfe9f88542451cc1045b5f3

Contents?: true

Size: 1002 Bytes

Versions: 13

Compression:

Stored size: 1002 Bytes

Contents

module Dry::Initializer::Plugins
  # Base class for plugins
  #
  # A plugin should has class method [.call] that takes argument name and
  # settings and return a chunk of code for the #initialize method body.
  #
  class Base
    include Dry::Initializer::Errors

    # Builds the proc for the `__after_initializer__` callback
    #
    # @param [#to_s] name
    # @param [Hash<Symbol, Object>] settings
    #
    # @return [String, Proc, nil]
    #
    def self.call(name, settings)
      new(name, settings).call
    end

    # @private
    attr_reader :name, :settings

    # Initializes a builder with argument name and settings
    # @param (see .call)
    def initialize(name, settings)
      @name     = name
      @settings = settings
    end

    # Checks equality to another instance by name
    # @return [Boolean]
    def ==(other)
      other.instance_of?(self.class) && (other.name == name)
    end

    # Builds a chunk of code
    # @return (see .call)
    def call
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dry-initializer-0.9.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.8.1 lib/dry/initializer/plugins/base.rb
dry-initializer-0.8.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.7.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.6.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.5.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.4.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.3.3 lib/dry/initializer/plugins/base.rb
dry-initializer-0.3.2 lib/dry/initializer/plugins/base.rb
dry-initializer-0.3.1 lib/dry/initializer/plugins/base.rb
dry-initializer-0.3.0 lib/dry/initializer/plugins/base.rb
dry-initializer-0.2.1 lib/dry/initializer/plugins/base.rb
dry-initializer-0.2.0 lib/dry/initializer/plugins/base.rb