Sha256: 997b9db81696fc74d95765e4229be055b118d983eb9e1a98af8d5a39aab42034
Contents?: true
Size: 884 Bytes
Versions: 23
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
23 entries across 23 versions & 1 rubygems