Class: Dry::Validation::Rust::MessageConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/validation/rust/config.rb

Overview

Configures the message backend used by compiled schemas.

Constant Summary collapse

BACKENDS =
{ yaml: YamlBackend, i18n: I18nBackend }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageConfig

Returns a new instance of MessageConfig.



14
15
16
17
18
19
# File 'lib/dry/validation/rust/config.rb', line 14

def initialize
  @backend = :yaml
  @default_locale = :en
  @top_namespace = :dry_validation
  @load_paths = []
end

Instance Attribute Details

#backend:yaml, ...

Returns the selected built-in identifier or custom backend class.

Returns:

  • (:yaml, :i18n, Class)

    the selected built-in identifier or custom backend class.



11
12
13
# File 'lib/dry/validation/rust/config.rb', line 11

def backend
  @backend
end

#default_localeObject

Returns the value of attribute default_locale.



12
13
14
# File 'lib/dry/validation/rust/config.rb', line 12

def default_locale
  @default_locale
end

#load_pathsObject

Returns the value of attribute load_paths.



12
13
14
# File 'lib/dry/validation/rust/config.rb', line 12

def load_paths
  @load_paths
end

#top_namespaceObject

Returns the value of attribute top_namespace.



12
13
14
# File 'lib/dry/validation/rust/config.rb', line 12

def top_namespace
  @top_namespace
end

Instance Method Details

#backend_classObject

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.



36
37
38
# File 'lib/dry/validation/rust/config.rb', line 36

def backend_class
  BACKENDS.fetch(backend, backend)
end

#dupObject



29
30
31
32
33
# File 'lib/dry/validation/rust/config.rb', line 29

def dup
  copy = super
  copy.load_paths = load_paths.dup
  copy
end