Class: UffizziCore::ComposeFile::Builders::ConfigFilesBuilderService
- Inherits:
-
Object
- Object
- UffizziCore::ComposeFile::Builders::ConfigFilesBuilderService
- Defined in:
- app/services/uffizzi_core/compose_file/builders/config_files_builder_service.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #build_attributes(config_files_data, dependencies) ⇒ Object
-
#initialize(project) ⇒ ConfigFilesBuilderService
constructor
A new instance of ConfigFilesBuilderService.
Constructor Details
#initialize(project) ⇒ ConfigFilesBuilderService
Returns a new instance of ConfigFilesBuilderService.
6 7 8 |
# File 'app/services/uffizzi_core/compose_file/builders/config_files_builder_service.rb', line 6 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
4 5 6 |
# File 'app/services/uffizzi_core/compose_file/builders/config_files_builder_service.rb', line 4 def project @project end |
Instance Method Details
#build_attributes(config_files_data, dependencies) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/uffizzi_core/compose_file/builders/config_files_builder_service.rb', line 10 def build_attributes(config_files_data, dependencies) return [] if config_files_data.empty? config_file_sources = dependencies.pluck(:source) config_files = project.config_files.with_creation_source(UffizziCore::ConfigFile.creation_source.compose_file) .by_source(config_file_sources) config_files_data.map do |config_file_data| detected_dependency = dependencies.detect { |dependency| dependency[:path] == config_file_data[:source] } detected_config_file = config_files.detect { |config_file| config_file.source == detected_dependency[:source] } if detected_config_file.nil? raise UffizziCore::ComposeFile::BuildError, I18n.t('compose.config_file_not_found', name: config_file_data[:source]) end { mount_path: config_file_data[:target], config_file_id: detected_config_file.id, } end end |