Sha256: e20fdee5186f65f719dcd6d80ca93d066f3309eb2998a70a02b86678c0a6ccee
Contents?: true
Size: 884 Bytes
Versions: 19
Compression:
Stored size: 884 Bytes
Contents
# frozen_string_literal: true module Dry module Schema # An API for configuring message backends # # @api private module Messages BACKENDS = { i18n: 'I18n', yaml: 'YAML' }.freeze module_function public def setup(config) backend_class = BACKENDS.fetch(config.backend) do raise "+#{config.backend}+ is not a valid messages identifier" end namespace = config.namespace options = config.to_h.select { |k, _| Abstract.settings.include?(k) } messages = Messages.const_get(backend_class).build(options) return messages.namespaced(namespace) if namespace messages end end end end require 'dry/schema/messages/abstract' require 'dry/schema/messages/namespaced' require 'dry/schema/messages/yaml' require 'dry/schema/messages/i18n' if defined?(I18n)
Version data entries
19 entries across 19 versions & 1 rubygems