Module: Dry::Schema::Messages Private

Defined in:
lib/dry/schema/messages.rb,
lib/dry/schema/messages/abstract.rb,
lib/dry/schema/messages/template.rb,
lib/dry/schema/messages/namespaced.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

An API for configuring message backends

Defined Under Namespace

Classes: Abstract, I18n, Namespaced, Template, YAML

Class Method Summary collapse

Class Method Details

.build(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
27
28
29
# File 'lib/dry/schema/messages.rb', line 22

def self.build(config)
  case config.messages
  when :yaml then default
  when :i18n then Messages::I18n.new
  else
    raise "+#{config.messages}+ is not a valid messages identifier"
  end
end

.defaultObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/dry/schema/messages.rb', line 32

def self.default
  Messages::YAML.load
end

.setup(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dry/schema/messages.rb', line 7

def self.setup(config)
  messages = build(config)

  if config.messages_file && config.namespace
    messages.merge(config.messages_file).namespaced(config.namespace)
  elsif config.messages_file
    messages.merge(config.messages_file)
  elsif config.namespace
    messages.namespaced(config.namespace)
  else
    messages
  end
end