class KuberKit::TemplateReader::Reader
Constants
- ReaderNotFoundError
Public Class Methods
new(**injected_deps, &block)
click to toggle source
Calls superclass method
# File lib/kuber_kit/template_reader/reader.rb, line 8 def initialize(**injected_deps, &block) super(**injected_deps) add_default_strategies end
Public Instance Methods
read(shell, template)
click to toggle source
# File lib/kuber_kit/template_reader/reader.rb, line 23 def read(shell, template) reader = @@readers[template.class] raise ReaderNotFoundError, "Can't find reader for template #{template}" if reader.nil? reader.read(shell, template) end
reset!()
click to toggle source
# File lib/kuber_kit/template_reader/reader.rb, line 31 def reset! @@readers = {} end
use_reader(template_reader, template_class:)
click to toggle source
# File lib/kuber_kit/template_reader/reader.rb, line 13 def use_reader(template_reader, template_class:) @@readers ||= {} if !template_reader.is_a?(KuberKit::TemplateReader::Strategies::Abstract) raise ArgumentError.new("should be an instance of KuberKit::TemplateReader::Strategies::Abstract, got: #{template_reader.inspect}") end @@readers[template_class] = template_reader end
Private Instance Methods
add_default_strategies()
click to toggle source
# File lib/kuber_kit/template_reader/reader.rb, line 36 def add_default_strategies use_reader(artifact_file, template_class: KuberKit::Core::Templates::ArtifactFile) end