Module: DSLCompose::SharedConfiguration
- Defined in:
- lib/dsl_compose/shared_configuration.rb
Overview
This module is used to store shared configuration blocks which can be imported and used within your base or method dsl configuration blocks.
Defined Under Namespace
Classes: InvalidSharedConfigurationNameError, NoBlockProvidedError, SharedConfigurationAlreadyExistsError, SharedConfigurationDoesNotExistError
Class Method Summary collapse
-
.add(name, &block) ⇒ Object
takes a name and a block and stores it in the shared_configuration hash if a block with this name already exists, it raises an error.
-
.clear ⇒ Object
clears the shared_configuration hash, this is typically used from the test suite.
-
.get(name) ⇒ Object
takes a name and returns the block stored in the shared_configuration hash if a block with this name does not exist, it raises an error.
Class Method Details
.add(name, &block) ⇒ Object
takes a name and a block and stores it in the shared_configuration hash if a block with this name already exists, it raises an error
21 22 23 24 25 26 27 28 |
# File 'lib/dsl_compose/shared_configuration.rb', line 21 def self.add name, &block raise InvalidSharedConfigurationNameError unless name.is_a?(Symbol) raise SharedConfigurationAlreadyExistsError if @shared_configuration&.key?(name) raise NoBlockProvidedError if block.nil? @shared_configuration ||= {} @shared_configuration[name] = block end |
.clear ⇒ Object
clears the shared_configuration hash, this is typically used from the test suite
40 41 42 |
# File 'lib/dsl_compose/shared_configuration.rb', line 40 def self.clear @shared_configuration = {} end |
.get(name) ⇒ Object
takes a name and returns the block stored in the shared_configuration hash if a block with this name does not exist, it raises an error
32 33 34 35 36 37 |
# File 'lib/dsl_compose/shared_configuration.rb', line 32 def self.get name raise InvalidSharedConfigurationNameError unless name.is_a?(Symbol) raise SharedConfigurationDoesNotExistError unless @shared_configuration&.key?(name) @shared_configuration[name] end |