Class: Etcher::Registry

Inherits:
Data
  • Object
show all
Defined in:
lib/etcher/registry.rb

Overview

Provides a registry of customization for loading and resolving a configuration.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contract: Contract, model: Hash, loaders: [], transformers: []) ⇒ Registry

Returns a new instance of Registry.



14
15
16
# File 'lib/etcher/registry.rb', line 14

def initialize contract: Contract, model: Hash, loaders: [], transformers: []
  super
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract

Returns:

  • (Object)

    the current value of contract



5
6
7
# File 'lib/etcher/registry.rb', line 5

def contract
  @contract
end

#loadersObject (readonly)

Returns the value of attribute loaders

Returns:

  • (Object)

    the current value of loaders



5
6
7
# File 'lib/etcher/registry.rb', line 5

def loaders
  @loaders
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



5
6
7
# File 'lib/etcher/registry.rb', line 5

def model
  @model
end

#transformersObject (readonly)

Returns the value of attribute transformers

Returns:

  • (Object)

    the current value of transformers



5
6
7
# File 'lib/etcher/registry.rb', line 5

def transformers
  @transformers
end

Class Method Details

.find(namespace, moniker, logger: LOGGER) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/etcher/registry.rb', line 6

def self.find namespace, moniker, logger: LOGGER
  case Finder.call namespace, moniker
    in Success(constant) then constant
    in Failure(message) then logger.abort message
    else logger.abort "Unable to find constant in registry."
  end
end

Instance Method Details

#add_loader(loader) ⇒ Object



18
# File 'lib/etcher/registry.rb', line 18

def add_loader(loader, ...) = add(loader, :Loaders, ...)

#add_transformer(transformer) ⇒ Object



22
# File 'lib/etcher/registry.rb', line 22

def add_transformer(transformer, ...) = add(transformer, :Transformers, ...)

#remove_loader(index) ⇒ Object



20
# File 'lib/etcher/registry.rb', line 20

def remove_loader(index) = remove index, loaders

#remove_transformer(index) ⇒ Object



24
# File 'lib/etcher/registry.rb', line 24

def remove_transformer(index) = remove index, transformers