Sha256: 25948b76ec3a9b22d38c3ccfebe72adfd2a6d73bdb12b44d26997a56ae1e8e75

Contents?: true

Size: 852 Bytes

Versions: 4

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

module Script
  module Layers
    module Domain
      class ScriptConfig
        attr_reader :content, :version, :title, :description, :configuration_ui, :configuration

        REQUIRED_FIELDS = %w(version title)

        def initialize(content:)
          validate_content!(content)

          @content = content
          @version = @content["version"].to_s
          @title = @content["title"]
          @description = @content["description"]
          @configuration_ui = @content.fetch("configurationUi", true)
          @configuration = @content["configuration"]
        end

        private

        def validate_content!(content)
          REQUIRED_FIELDS.each do |field|
            raise Errors::MissingScriptConfigFieldError, field if content[field].nil?
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shopify-cli-2.9.0 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.8.0 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.7.4 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.7.3 lib/project_types/script/layers/domain/script_config.rb