Class: Extension::Models::ServerConfig::Extension

Inherits:
Base
  • Object
show all
Includes:
SmartProperties
Defined in:
lib/project_types/extension/models/server_config/extension.rb

Class Method Summary collapse

Methods inherited from Base

#to_h, #to_hash

Class Method Details

.build(uuid: "", template:, type:, root_dir:, **args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/project_types/extension/models/server_config/extension.rb', line 20

def self.build(uuid: "", template:, type:, root_dir:, **args)
  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
    ),
    capabilities: ServerConfig::Capabilities.new(
      network_access: false
    ),
    metafields: args.delete(:metafields)
  )
end

.generate_dev_uuidObject



40
41
42
# File 'lib/project_types/extension/models/server_config/extension.rb', line 40

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