Sha256: 5d0f0d365b69b97fdd947fa19b697bc91b7ffa785ee2467cf1413382f0eb8b30

Contents?: true

Size: 849 Bytes

Versions: 9

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

require 'dry/configurable/config'
require 'dry/configurable/methods'

module Dry
  module Configurable
    # Instance-level API when `Dry::Configurable` is included in a class
    #
    # @api public
    module InstanceMethods
      include Methods

      # Return object's configuration
      #
      # @return [Config]
      #
      # @api public
      attr_reader :config

      # @api private
      def initialize(*)
        @config = Config.new(self.class._settings.dup)
        super
      end

      # Finalize the config and freeze the object
      #
      # @api public
      def finalize!
        return self if frozen?

        super
        freeze
      end

      private

      # @api public
      def initialize_copy(source)
        super
        @config = source.config.dup
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
dry-configurable-0.12.0 lib/dry/configurable/instance_methods.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/dry-configurable-0.11.6/lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.6 lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.5 lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.4 lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.3 lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.2 lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.1 lib/dry/configurable/instance_methods.rb
dry-configurable-0.11.0 lib/dry/configurable/instance_methods.rb