class Dry::Schema::Messages::Namespaced

Namespaced messages backend

@api public

Attributes

call_opts[R]

@api private

config[R]

@api private

messages[R]

@api private

namespace[R]

@api private

Public Class Methods

new(namespace, messages) click to toggle source

@api private

Calls superclass method
# File lib/dry/schema/messages/namespaced.rb, line 23
def initialize(namespace, messages)
  super()
  @config = messages.config
  @namespace = namespace
  @messages = messages
  @call_opts = {namespace: namespace}.freeze
end

Public Instance Methods

[](key, options = {})
Alias for: call
cache_key(predicate, options) click to toggle source

@api private

# File lib/dry/schema/messages/namespaced.rb, line 72
def cache_key(predicate, options)
  messages.cache_key(predicate, options)
end
call(key, options = {}) click to toggle source

@api public

Calls superclass method Dry::Schema::Messages::Abstract#call
# File lib/dry/schema/messages/namespaced.rb, line 44
def call(key, options = {})
  super(key, options.empty? ? call_opts : options.merge(call_opts))
end
Also aliased as: []
filled_lookup_paths(tokens) click to toggle source

@api private

# File lib/dry/schema/messages/namespaced.rb, line 59
def filled_lookup_paths(tokens)
  super(tokens.merge(root: "#{tokens[:root]}.#{namespace}")) + super
end
get(key, options = {}) click to toggle source

Get a message for the given key and its options

@param [Symbol] key @param [Hash] options

@return [String]

@api public

# File lib/dry/schema/messages/namespaced.rb, line 39
def get(key, options = {})
  messages.get(key, options)
end
interpolatable_data(key, options, **data) click to toggle source

@api private

# File lib/dry/schema/messages/namespaced.rb, line 77
def interpolatable_data(key, options, **data)
  messages.interpolatable_data(key, options, **data)
end
interpolate(key, options, **data) click to toggle source

@api private

# File lib/dry/schema/messages/namespaced.rb, line 82
def interpolate(key, options, **data)
  messages.interpolate(key, options, **data)
end
key?(key, *args) click to toggle source

Check if given key is defined

@return [Boolean]

@api public

# File lib/dry/schema/messages/namespaced.rb, line 54
def key?(key, *args)
  messages.key?(key, *args)
end
rule_lookup_paths(tokens) click to toggle source

@api private

# File lib/dry/schema/messages/namespaced.rb, line 64
def rule_lookup_paths(tokens)
  base_paths = messages.rule_lookup_paths(tokens)
  base_paths.map { |key|
    key.sub(config.top_namespace, "#{config.top_namespace}.#{namespace}")
  } + base_paths
end
translate(key, **args) click to toggle source

@api private

# File lib/dry/schema/messages/namespaced.rb, line 87
def translate(key, **args)
  messages.translate(key, **args)
end