Sha256: 07152dcf6b48d943c1b246dba3e153c329a0526d7423ae12448a67aaeba16083

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "dry/validation/contract"

module Dry
  module Rails
    module Features
      # Abstract application contract class used by the `:application_contract` feature
      #
      # This is an abstract class that's pre-configured during booting process to serve as the base
      # class that the ApplicationContract class inherits from.
      #
      # @see https://dry-rb.org/gems/dry-validation/1.5/configuration/
      #
      # @abstract
      #
      # @api public
      class ApplicationContract < Dry::Validation::Contract
        # This is called during the booting process of the `:application_contract` feature
        #
        # @param railtie [Dry::Rails::Railtie]
        #
        # @return [Class]
        #
        # @api private
        def self.finalize!(railtie)
          load_paths = Dir[railtie.container.root.join("config/locales/*.yml")]

          config.messages.top_namespace = :contracts
          config.messages.backend = :i18n
          config.messages.load_paths += load_paths

          self
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-rails-0.5.0 lib/dry/rails/features/application_contract.rb
dry-rails-0.4.0 lib/dry/rails/features/application_contract.rb
dry-rails-0.3.0 lib/dry/rails/features/application_contract.rb
dry-rails-0.2.1 lib/dry/rails/features/application_contract.rb
dry-rails-0.2.0 lib/dry/rails/features/application_contract.rb
dry-rails-0.1.0 lib/dry/rails/features/application_contract.rb