- Parent Namespace
- SleepingKingStudios::Tools
- Inherited Classes
- SleepingKingStudios::Tools::Base
>
Object
- Defined In
- lib/sleeping_king_studios/tools/messages.rb
Table Of Contents
Overview
Utility for generating configured, user-readable output strings.
Back To Top
Defined Under Namespace
- Classes
- Registry,
Strategy
- Modules
- Strategies
Back To Top
Class Methods
- Inherited From
- SleepingKingStudios::Tools::Base
Deprecated. v1.3.0 Use Toolbelt.instance instead.
Returns
Back To Top
Constructor
#initialize(registry:, toolbelt: nil) => Messages
Parameters
Returns
- (Messages) — a new instance of Messages
Back To Top
Instance Attributes
Returns
Back To Top
Instance Methods
#message(key, parameters: {}, scope: nil, **options) => Object
Also known as:
get
Generates a message from the given key, scope, and parameters.
Internally, finds a messages strategy matching the combined key and
scope and calls that strategy.
If a strategy is not found, or if the strategy does not define a message
for the key, you can provide a default value.
- If the default value is a Proc, it will be called with the fully
scoped key, as a positional argument as well as any additional
keywords passed to #call. The value returned by the Proc will be
returned by #call.
- If the default value is any other Object (including nil), the default
value will be returned by #call.
- If a default value is not provided, a missing message warning will be
generated and returned.
Parameters
- key (String, Symbol) — the key used to resolve the message.
- default (Object) — the default value to return if there is no
defined registry for the message, or if the strategy does not define a
message for the key.
- parameters (Hash) — the parameters used to generate the message,
such as values for a template string.
- scope (String) — the namespace for the key. Combined with the given
key to generate the scoped key value.
- options (Hash) — additional options for resolving or generating the
message.
Also known as:
tools
- Inherited From
- SleepingKingStudios::Tools::Base
Back To Top
Back to
Documentation |
Reference
|
SleepingKingStudios
|
SleepingKingStudios::Tools