Sha256: 4b862ec7dd17da6c7dff3d43c990abcc1c0ff58d17114573bb0c930192332437

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "securerandom"

module Extension
  module Models
    module ServerConfig
      class Extension < Base
        include SmartProperties

        property! :uuid, accepts: String
        property! :type, accepts: String
        property! :user, accepts: ServerConfig::User
        property! :development, accepts: ServerConfig::Development
        property :extension_points, accepts: Array

        def self.build(uuid: "", template:, type:, root_dir:)
          renderer = ServerConfig::DevelopmentRenderer.find(type)
          entry = ServerConfig::DevelopmentEntries.find(template)
          new(
            uuid: uuid.empty? ? generate_dev_uuid : uuid,
            type: type.downcase,
            user: ServerConfig::User.new,
            development: ServerConfig::Development.new(
              root_dir: root_dir,
              template: template,
              renderer: renderer,
              entries: entry
            )
          )
        end

        def self.generate_dev_uuid
          "dev-#{SecureRandom.uuid}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-cli-2.6.6 lib/project_types/extension/models/server_config/extension.rb