Class: Dry::Schema::Messages::Namespaced
- Defined in:
- lib/dry/schema/messages/namespaced.rb
Overview
Namespaced messages backend
Constant Summary
Constants inherited from Abstract
Instance Attribute Summary collapse
- #messages ⇒ Object readonly private
- #namespace ⇒ Object readonly private
- #root ⇒ Object readonly private
Attributes inherited from Abstract
Instance Method Summary collapse
-
#get(key, options = {}) ⇒ String
Get a message for the given key and its options.
-
#initialize(namespace, messages) ⇒ Namespaced
constructor
private
A new instance of Namespaced.
-
#key?(key, *args) ⇒ Boolean
Check if given key is defined.
- #lookup_paths(tokens) ⇒ Object private
Methods inherited from Abstract
cache, #cache, #call, #default_locale, #hash, #lookup, #namespaced, #rule
Constructor Details
#initialize(namespace, messages) ⇒ Namespaced
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.
Returns a new instance of Namespaced.
18 19 20 21 22 23 |
# File 'lib/dry/schema/messages/namespaced.rb', line 18 def initialize(namespace, ) super() @namespace = namespace = @root = .root end |
Instance Attribute Details
#messages ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/dry/schema/messages/namespaced.rb', line 12 def end |
#namespace ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/dry/schema/messages/namespaced.rb', line 9 def namespace @namespace end |
#root ⇒ Object (readonly)
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.
15 16 17 |
# File 'lib/dry/schema/messages/namespaced.rb', line 15 def root @root end |
Instance Method Details
#get(key, options = {}) ⇒ String
Get a message for the given key and its options
33 34 35 |
# File 'lib/dry/schema/messages/namespaced.rb', line 33 def get(key, = {}) .get(key, ) end |
#key?(key, *args) ⇒ Boolean
Check if given key is defined
42 43 44 |
# File 'lib/dry/schema/messages/namespaced.rb', line 42 def key?(key, *args) .key?(key, *args) end |
#lookup_paths(tokens) ⇒ 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.
47 48 49 |
# File 'lib/dry/schema/messages/namespaced.rb', line 47 def lookup_paths(tokens) super(tokens.merge(root: "#{root}.rules.#{namespace}")) + super end |