Class: RubyYacht::App::DSL

Inherits:
Object
  • Object
show all
Extended by:
DSL::Base::ClassMethods
Includes:
DSL::Base
Defined in:
lib/ruby_yacht/dsl/app.rb

Overview

This class provide's the DSL for configuring an app.

Inside of the project configuration, you can call app [name] to add an app, and then pass it a block to configure the app, which will allow you to call these DSL methods.

Instance Method Summary collapse

Methods included from DSL::Base::ClassMethods

add_attribute, add_boolean, add_generic_attribute, add_list, add_object, add_object_list, all_attributes, copied_attributes, created_type, creates_object, custom_attribute_method, default_values, required_attributes

Methods included from DSL::Base

#create_object, #load_custom_attributes, #run

Constructor Details

#initialize(name, server_type = nil) ⇒ DSL

This initializer starts the DSL for the app.

Parameters

  • name: String The name of the app.

65
66
67
68
69
# File 'lib/ruby_yacht/dsl/app.rb', line 65

def initialize(name, server_type = nil)
  @name = name.to_sym
  @server_type = server_type
  load_custom_attributes
end

Instance Method Details

#check_required_attributesObject

This method checks that all of the required attributes have been set on the object.

If they haven't, this will raise an exception.

It also checks that the server type has been defined in the configuration.


103
104
105
106
107
108
109
# File 'lib/ruby_yacht/dsl/app.rb', line 103

def check_required_attributes
  super
  server_type = RubyYacht.configuration.find_server_type(@server_type)
  unless server_type && server_type.container_type == :app
    raise "App has invalid server type `#{@server_type}`"
  end
end

#database_nameObject

:method: database_name You can call database 'foo' to tell the app to use the database server named foo.


82
# File 'lib/ruby_yacht/dsl/app.rb', line 82

add_attribute :database_name, nil, false

#portObject

:method: port You can call port 3000 to set the app's port. It defaults to 8080.


92
# File 'lib/ruby_yacht/dsl/app.rb', line 92

add_attribute :port, 8080

#repository_nameObject

:method: repository_name You can call repository_name 'foo/bar' to set the app's repository_name.


76
# File 'lib/ruby_yacht/dsl/app.rb', line 76

add_attribute :repository_name

#server_typeObject

:method: server_type You can call server_type :foo to set the app's server_type.


87
# File 'lib/ruby_yacht/dsl/app.rb', line 87

add_attribute :server_type