Skip to content

Commit de645c6

Browse files
committed
Change HashConfig documentation to be markdown
1 parent 4d1d7d3 commit de645c6

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

activerecord/lib/active_record/database_configurations/hash_config.rb

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
11
# frozen_string_literal: true
22

3+
# :markup: markdown
4+
35
module ActiveRecord
46
class DatabaseConfigurations
5-
# = Active Record Database Hash Config
7+
# # Active Record Database Hash Config
68
#
7-
# A +HashConfig+ object is created for each database configuration entry that
8-
# is created from a hash.
9+
# A `HashConfig` object is created for each database configuration entry that is
10+
# created from a hash.
911
#
1012
# A hash config:
1113
#
12-
# { "development" => { "database" => "db_name" } }
14+
# { "development" => { "database" => "db_name" } }
1315
#
1416
# Becomes:
1517
#
16-
# #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
17-
# @env_name="development", @name="primary", @config={database: "db_name"}>
18+
# #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
19+
# @env_name="development", @name="primary", @config={database: "db_name"}>
1820
#
1921
# See ActiveRecord::DatabaseConfigurations for more info.
2022
class HashConfig < DatabaseConfig
2123
attr_reader :configuration_hash
2224

23-
# Initialize a new +HashConfig+ object
25+
# Initialize a new `HashConfig` object
26+
#
27+
# #### Parameters
2428
#
25-
# ==== Parameters
29+
# * `env_name` - The Rails environment, i.e. "development".
30+
# * `name` - The db config name. In a standard two-tier database configuration
31+
# this will default to "primary". In a multiple database three-tier database
32+
# configuration this corresponds to the name used in the second tier, for
33+
# example "primary_readonly".
34+
# * `configuration_hash` - The config hash. This is the hash that contains the
35+
# database adapter, name, and other important information for database
36+
# connections.
2637
#
27-
# * <tt>env_name</tt> - The \Rails environment, i.e. "development".
28-
# * <tt>name</tt> - The db config name. In a standard two-tier
29-
# database configuration this will default to "primary". In a multiple
30-
# database three-tier database configuration this corresponds to the name
31-
# used in the second tier, for example "primary_readonly".
32-
# * <tt>configuration_hash</tt> - The config hash. This is the hash that contains the
33-
# database adapter, name, and other important information for database
34-
# connections.
3538
def initialize(env_name, name, configuration_hash)
3639
super(env_name, name)
3740
@configuration_hash = configuration_hash.symbolize_keys.freeze
3841
end
3942

4043
# Determines whether a database configuration is for a replica / readonly
41-
# connection. If the +replica+ key is present in the config, +replica?+ will
42-
# return +true+.
44+
# connection. If the `replica` key is present in the config, `replica?` will
45+
# return `true`.
4346
def replica?
4447
configuration_hash[:replica]
4548
end
4649

47-
# The migrations paths for a database configuration. If the
48-
# +migrations_paths+ key is present in the config, +migrations_paths+
49-
# will return its value.
50+
# The migrations paths for a database configuration. If the `migrations_paths`
51+
# key is present in the config, `migrations_paths` will return its value.
5052
def migrations_paths
5153
configuration_hash[:migrations_paths]
5254
end
@@ -91,8 +93,8 @@ def checkout_timeout
9193
(configuration_hash[:checkout_timeout] || 5).to_f
9294
end
9395

94-
# +reaping_frequency+ is configurable mostly for historical reasons, but it could
95-
# also be useful if someone wants a very low +idle_timeout+.
96+
# `reaping_frequency` is configurable mostly for historical reasons, but it
97+
# could also be useful if someone wants a very low `idle_timeout`.
9698
def reaping_frequency
9799
configuration_hash.fetch(:reaping_frequency, 60)&.to_f
98100
end
@@ -106,9 +108,8 @@ def adapter
106108
configuration_hash[:adapter]&.to_s
107109
end
108110

109-
# The path to the schema cache dump file for a database.
110-
# If omitted, the filename will be read from ENV or a
111-
# default will be derived.
111+
# The path to the schema cache dump file for a database. If omitted, the
112+
# filename will be read from ENV or a default will be derived.
112113
def schema_cache_path
113114
configuration_hash[:schema_cache_path]
114115
end
@@ -129,14 +130,14 @@ def primary? # :nodoc:
129130
Base.configurations.primary?(name)
130131
end
131132

132-
# Determines whether to dump the schema/structure files and the
133-
# filename that should be used.
133+
# Determines whether to dump the schema/structure files and the filename that
134+
# should be used.
134135
#
135-
# If +configuration_hash[:schema_dump]+ is set to +false+ or +nil+
136-
# the schema will not be dumped.
136+
# If `configuration_hash[:schema_dump]` is set to `false` or `nil` the schema
137+
# will not be dumped.
137138
#
138-
# If the config option is set that will be used. Otherwise \Rails
139-
# will generate the filename from the database config name.
139+
# If the config option is set that will be used. Otherwise Rails will generate
140+
# the filename from the database config name.
140141
def schema_dump(format = ActiveRecord.schema_format)
141142
if configuration_hash.key?(:schema_dump)
142143
if config = configuration_hash[:schema_dump]

0 commit comments

Comments
 (0)