Sha256: b6fceac8ba1d28ff84571a7c2d971c1faeb3e8d7b3718600f675664835d29dea

Contents?: true

Size: 860 Bytes

Versions: 11

Compression:

Stored size: 860 Bytes

Contents

class KuberKit::ServiceGenerator::Generator
  StrategyNotFoundError = Class.new(KuberKit::NotFoundError)

  include KuberKit::Import[
    "core.service_store",
  ]

  def register_strategy(strategy_name, strategy)
    @@strategies ||= {}

    if !strategy.is_a?(KuberKit::ServiceGenerator::Strategies::Abstract)
      raise ArgumentError.new("should be an instance of KuberKit::ServiceGenerator::Strategies::Abstract, got: #{strategy.inspect}")
    end

    @@strategies[strategy_name] = strategy
  end

  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service, String, Symbol => Any
  def generate(shell, service, export_path, strategy_name)
    generator = @@strategies[strategy_name]

    raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if generator.nil?

    generator.generate(shell, service, export_path)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kuber_kit-1.3.9 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.8 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.7 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.1.8 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.6 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.1.7 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.5 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.4 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.1.6 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.3 lib/kuber_kit/service_generator/generator.rb
kuber_kit-1.3.2 lib/kuber_kit/service_generator/generator.rb