Class: RubyYacht::Database::DSL

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

Overview

This class provides a DSL for configuring a database.

You can access this DSL by calling database within RubyYacht::Project::DSL. It will create a RubyYacht::Database

Instance Method Summary collapse

Methods included from RubyYacht::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 RubyYacht::DSL::Base

#check_server_type, #create_object, #load_custom_attributes, #run

Constructor Details

#initialize(server_type, name) ⇒ DSL

This initializer starts the DSL for the database.

Parameters

  • server_type: Symbol The type of database this is.
  • name: String The name of the database.


64
65
66
67
68
# File 'lib/ruby_yacht/dsl/database.rb', line 64

def initialize(server_type, name)
  @server_type = server_type
  @name = name
  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.



120
121
122
123
# File 'lib/ruby_yacht/dsl/database.rb', line 120

def check_required_attributes
  super
  check_server_type @server_type, :database
end

#container_labelObject

:method: container_label You can call container_label 'mysql' to give this database a container name that is (project)-mysql.



109
# File 'lib/ruby_yacht/dsl/database.rb', line 109

add_attribute :container_label, :database

#hostObject

:method: host You can call host 'db.test.com' to set the database's host.



73
# File 'lib/ruby_yacht/dsl/database.rb', line 73

add_attribute :host

#passwordObject

:method: password You can call password 'testpass' to tell the apps to connect to the password testpass.



97
# File 'lib/ruby_yacht/dsl/database.rb', line 97

add_attribute :password

#portObject

:method: port You can call port 1234 to tell the database server to listen on port 1234.



103
# File 'lib/ruby_yacht/dsl/database.rb', line 103

add_attribute :port

#usernameObject

:method: username You can call username 'db-user' to tell the apps to connect to the database under the name db-user.



91
# File 'lib/ruby_yacht/dsl/database.rb', line 91

add_attribute :username