Class: TTY::Config::MarshallerRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/config/marshaller_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.


10
11
12
# File 'lib/tty/config/marshaller_registry.rb', line 10

def initialize(mappings = {})
  @marshallers = mappings
end

Instance Attribute Details

#marshallersObject (readonly)

Returns the value of attribute marshallers


7
8
9
# File 'lib/tty/config/marshaller_registry.rb', line 7

def marshallers
  @marshallers
end

Instance Method Details

#[](name) ⇒ Object


38
39
40
# File 'lib/tty/config/marshaller_registry.rb', line 38

def [](name)
  marshallers.fetch(name)
end

#extsObject


22
23
24
# File 'lib/tty/config/marshaller_registry.rb', line 22

def exts
  marshallers.values.reduce([]) { |acc, obj| acc + obj.ext }
end

#namesObject


14
15
16
# File 'lib/tty/config/marshaller_registry.rb', line 14

def names
  marshallers.keys
end

#objectsObject


18
19
20
# File 'lib/tty/config/marshaller_registry.rb', line 18

def objects
  marshallers.values
end

#register(name, object) ⇒ Object


30
31
32
# File 'lib/tty/config/marshaller_registry.rb', line 30

def register(name, object)
  marshallers[name] = object
end

#registered?(name_or_object) ⇒ Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/tty/config/marshaller_registry.rb', line 26

def registered?(name_or_object)
  marshallers.key?(name_or_object) || marshallers.has_value?(name_or_object)
end

#unregister(name) ⇒ Object


34
35
36
# File 'lib/tty/config/marshaller_registry.rb', line 34

def unregister(name)
  marshallers.delete(name)
end