Module: Dcc::ContextOptions
- Defined in:
- lib/dcc/context_options.rb
Class Method Summary collapse
- .context_specified?(context) ⇒ Boolean
-
.normalize_context_option(context:, register:, default_context:, warning_source:) ⇒ Object
Collapse the public
context:andregister:options into a single context id symbol (ornilto fall back to the caller's default). -
.normalize_context_reference(reference) ⇒ Object
Coerce any acceptable context reference (Symbol, String, or
Lutaml::Xml::Namespace) into a Symbol.
Class Method Details
.context_specified?(context) ⇒ Boolean
35 36 37 |
# File 'lib/dcc/context_options.rb', line 35 def context_specified?(context) !context.equal?(::Dcc::UNSPECIFIED_CONTEXT) end |
.normalize_context_option(context:, register:, default_context:, warning_source:) ⇒ Object
Collapse the public context: and register: options into a single
context id symbol (or nil to fall back to the caller's default).
16 17 18 19 20 21 22 |
# File 'lib/dcc/context_options.rb', line 16 def normalize_context_option(context:, register:, default_context:, warning_source:) raise_if_conflicting!(context, register) return normalize_context_reference(register) || default_context if register return default_context unless context_specified?(context) normalize_context_reference(context) || default_context end |
.normalize_context_reference(reference) ⇒ Object
Coerce any acceptable context reference (Symbol, String, or
Lutaml::Xml::Namespace) into a Symbol.
26 27 28 29 30 31 32 33 |
# File 'lib/dcc/context_options.rb', line 26 def normalize_context_reference(reference) return nil if reference.nil? return reference if reference.is_a?(Symbol) return reference.to_sym if reference.is_a?(String) return reference.id.to_sym if reference.is_a?(::Lutaml::Xml::Namespace) raise ArgumentError, "Unsupported context/register reference: #{reference.inspect}" end |