Class: RubyYacht::Database
- Inherits:
-
Object
- Object
- RubyYacht::Database
- Defined in:
- lib/ruby_yacht/dsl/database.rb
Overview
This class stores the configuration for a project's database server.
You can configure a database with RubyYacht::Database::DSL
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#container_label ⇒ Object
The database-specific part of the container name for this database.
-
#host ⇒ Object
The host that the database server is accessed on.
-
#name ⇒ Object
The name of the database.
-
#password ⇒ Object
The password we use to connect to the database.
-
#port ⇒ Object
The port the database server should listen on.
-
#server_type ⇒ Object
The type of database server we're using.
-
#username ⇒ Object
The username we use to connect to the database.
Instance Method Summary collapse
-
#apps ⇒ Object
The apps that connect to this database.
-
#container_name ⇒ Object
This method gets the name of the container and image for this database.
-
#local? ⇒ Boolean
Whether the database is running on the same machine as the app servers.
-
#project ⇒ Object
The project that contains this database.
Instance Attribute Details
#container_label ⇒ Object
The database-specific part of the container name for this database.
25 26 27 |
# File 'lib/ruby_yacht/dsl/database.rb', line 25 def container_label @container_label end |
#host ⇒ Object
The host that the database server is accessed on.
7 8 9 |
# File 'lib/ruby_yacht/dsl/database.rb', line 7 def host @host end |
#name ⇒ Object
The name of the database
10 11 12 |
# File 'lib/ruby_yacht/dsl/database.rb', line 10 def name @name end |
#password ⇒ Object
The password we use to connect to the database
19 20 21 |
# File 'lib/ruby_yacht/dsl/database.rb', line 19 def password @password end |
#port ⇒ Object
The port the database server should listen on.
22 23 24 |
# File 'lib/ruby_yacht/dsl/database.rb', line 22 def port @port end |
#server_type ⇒ Object
The type of database server we're using.
13 14 15 |
# File 'lib/ruby_yacht/dsl/database.rb', line 13 def server_type @server_type end |
#username ⇒ Object
The username we use to connect to the database
16 17 18 |
# File 'lib/ruby_yacht/dsl/database.rb', line 16 def username @username end |
Instance Method Details
#apps ⇒ Object
The apps that connect to this database.
38 39 40 |
# File 'lib/ruby_yacht/dsl/database.rb', line 38 def apps project.apps.select { |app| app.database_name == self.name } end |
#container_name ⇒ Object
This method gets the name of the container and image for this database.
This will be the project's prefix followed by the database's container label.
46 47 48 |
# File 'lib/ruby_yacht/dsl/database.rb', line 46 def container_name "#{project.system_prefix}-#{container_label}" end |
#local? ⇒ Boolean
Whether the database is running on the same machine as the app servers.
28 29 30 |
# File 'lib/ruby_yacht/dsl/database.rb', line 28 def local? host == 'localhost' end |
#project ⇒ Object
The project that contains this database.
33 34 35 |
# File 'lib/ruby_yacht/dsl/database.rb', line 33 def project RubyYacht.configuration.projects.find { |project| project.databases.include?(self) } end |