Class: TTY::Config::MarshallerRegistry
- Inherits:
-
Object
- Object
- TTY::Config::MarshallerRegistry
- Defined in:
- lib/tty/config/marshaller_registry.rb
Instance Attribute Summary collapse
-
#marshallers ⇒ Object
readonly
private
All registered marshallers.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #exts ⇒ Object
-
#initialize(mappings = {}) ⇒ MarshallerRegistry
constructor
private
A new instance of MarshallerRegistry.
- #names ⇒ Object
- #objects ⇒ Object
- #register(name, object) ⇒ Object
- #registered?(name_or_object) ⇒ Boolean
- #unregister(name) ⇒ Object
Constructor Details
#initialize(mappings = {}) ⇒ MarshallerRegistry
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 MarshallerRegistry.
12 13 14 |
# File 'lib/tty/config/marshaller_registry.rb', line 12 def initialize(mappings = {}) @marshallers = mappings end |
Instance Attribute Details
#marshallers ⇒ 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.
All registered marshallers
9 10 11 |
# File 'lib/tty/config/marshaller_registry.rb', line 9 def marshallers @marshallers end |
Instance Method Details
#[](name) ⇒ Object
40 41 42 |
# File 'lib/tty/config/marshaller_registry.rb', line 40 def [](name) marshallers.fetch(name) end |
#exts ⇒ Object
24 25 26 |
# File 'lib/tty/config/marshaller_registry.rb', line 24 def exts marshallers.values.reduce([]) { |acc, obj| acc + obj.ext } end |
#names ⇒ Object
16 17 18 |
# File 'lib/tty/config/marshaller_registry.rb', line 16 def names marshallers.keys end |
#objects ⇒ Object
20 21 22 |
# File 'lib/tty/config/marshaller_registry.rb', line 20 def objects marshallers.values end |
#register(name, object) ⇒ Object
32 33 34 |
# File 'lib/tty/config/marshaller_registry.rb', line 32 def register(name, object) marshallers[name] = object end |
#registered?(name_or_object) ⇒ Boolean
28 29 30 |
# File 'lib/tty/config/marshaller_registry.rb', line 28 def registered?(name_or_object) marshallers.key?(name_or_object) || marshallers.value?(name_or_object) end |
#unregister(name) ⇒ Object
36 37 38 |
# File 'lib/tty/config/marshaller_registry.rb', line 36 def unregister(name) marshallers.delete(name) end |