Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
382a9563
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
382a9563
编写于
3月 21, 2019
作者:
Y
yuuji.yaginuma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix document formatting of Database configuration classes [ci skip]
* Show options as list. * Fix incorrect quoting.
上级
d2f9b8e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
35 deletion
+35
-35
activerecord/lib/active_record/database_configurations.rb
activerecord/lib/active_record/database_configurations.rb
+12
-12
activerecord/lib/active_record/database_configurations/hash_config.rb
.../lib/active_record/database_configurations/hash_config.rb
+11
-11
activerecord/lib/active_record/database_configurations/url_config.rb
...d/lib/active_record/database_configurations/url_config.rb
+12
-12
未找到文件。
activerecord/lib/active_record/database_configurations.rb
浏览文件 @
382a9563
...
...
@@ -17,22 +17,22 @@ def initialize(configurations = {})
end
# Collects the configs for the environment and optionally the specification
# name passed in. To include replica configurations pass
`include_replicas: true`
.
# name passed in. To include replica configurations pass
<tt>include_replicas: true</tt>
.
#
# If a spec name is provided a single DatabaseConfig object will be
# returned, otherwise an array of DatabaseConfig objects will be
# returned that corresponds with the environment and type requested.
#
#
Options:
#
==== Options
#
# <tt>env_name:</tt> The environment name. Defaults to +nil+ which will collect
# configs for all environments.
# <tt>spec_name:</tt> The specification name (i.e. primary, animals, etc.). Defaults
# to +nil+.
# <tt>include_replicas:</tt> Determines whether to include replicas in
# the returned list. Most of the time we're only iterating over the write
# connection (i.e. migrations don't need to run for the write and read connection).
# Defaults to +false+.
#
*
<tt>env_name:</tt> The environment name. Defaults to +nil+ which will collect
#
configs for all environments.
#
*
<tt>spec_name:</tt> The specification name (i.e. primary, animals, etc.). Defaults
#
to +nil+.
#
*
<tt>include_replicas:</tt> Determines whether to include replicas in
#
the returned list. Most of the time we're only iterating over the write
#
connection (i.e. migrations don't need to run for the write and read connection).
#
Defaults to +false+.
def
configs_for
(
env_name:
nil
,
spec_name:
nil
,
include_replicas:
false
)
configs
=
env_with_configs
(
env_name
)
...
...
@@ -53,7 +53,7 @@ def configs_for(env_name: nil, spec_name: nil, include_replicas: false)
# Returns the config hash that corresponds with the environment
#
# If the application has multiple databases
`default_hash`
will
# If the application has multiple databases
+default_hash+
will
# return the first config hash for the environment.
#
# { database: "my_db", adapter: "mysql2" }
...
...
@@ -65,7 +65,7 @@ def default_hash(env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call.to_s)
# Returns a single DatabaseConfig object based on the requested environment.
#
# If the application has multiple databases
`find_db_config`
will return
# If the application has multiple databases
+find_db_config+
will return
# the first DatabaseConfig for the environment.
def
find_db_config
(
env
)
configurations
.
find
do
|
db_config
|
...
...
activerecord/lib/active_record/database_configurations/hash_config.rb
浏览文件 @
382a9563
...
...
@@ -14,16 +14,16 @@ class DatabaseConfigurations
# #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10
# @env_name="development", @spec_name="primary", @config={"database"=>"db_name"}>
#
#
Options are:
#
==== Options
#
#
<tt>:env_name</tt> - The Rails environment, i.e. "development"
# <tt>:spec_name</tt> - The specification name. In a standard two-tier
# database configuration this will default to "primary". In a multiple
# database three-tier database configuration this corresponds to the name
# used in the second tier, for example "primary_readonly".
# <tt>:config</tt> - The config hash. This is the hash that contains the
# database adapter, name, and other important information for database
# connections.
#
* <tt>:env_name</tt> - The Rails environment, i.e. "development".
#
*
<tt>:spec_name</tt> - The specification name. In a standard two-tier
#
database configuration this will default to "primary". In a multiple
#
database three-tier database configuration this corresponds to the name
#
used in the second tier, for example "primary_readonly".
#
*
<tt>:config</tt> - The config hash. This is the hash that contains the
#
database adapter, name, and other important information for database
#
connections.
class
HashConfig
<
DatabaseConfig
attr_reader
:config
...
...
@@ -33,14 +33,14 @@ def initialize(env_name, spec_name, config)
end
# Determines whether a database configuration is for a replica / readonly
# connection. If the
`replica` key is present in the config, `replica?`
will
# connection. If the
+replica+ key is present in the config, +replica?+
will
# return +true+.
def
replica?
config
[
"replica"
]
end
# The migrations paths for a database configuration. If the
#
`migrations_paths` key is present in the config, `migrations_paths`
#
+migrations_paths+ key is present in the config, +migrations_paths+
# will return its value.
def
migrations_paths
config
[
"migrations_paths"
]
...
...
activerecord/lib/active_record/database_configurations/url_config.rb
浏览文件 @
382a9563
...
...
@@ -17,17 +17,17 @@ class DatabaseConfigurations
# @config={"adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost"},
# @url="postgres://localhost/foo">
#
#
Options are:
#
==== Options
#
#
<tt>:env_name</tt> - The Rails environment, ie "development"
# <tt>:spec_name</tt> - The specification name. In a standard two-tier
# database configuration this will default to "primary". In a multiple
# database three-tier database configuration this corresponds to the name
# used in the second tier, for example "primary_readonly".
# <tt>:url</tt> - The database URL.
# <tt>:config</tt> - The config hash. This is the hash that contains the
# database adapter, name, and other important information for database
# connections.
#
* <tt>:env_name</tt> - The Rails environment, ie "development".
#
*
<tt>:spec_name</tt> - The specification name. In a standard two-tier
#
database configuration this will default to "primary". In a multiple
#
database three-tier database configuration this corresponds to the name
#
used in the second tier, for example "primary_readonly".
#
*
<tt>:url</tt> - The database URL.
#
*
<tt>:config</tt> - The config hash. This is the hash that contains the
#
database adapter, name, and other important information for database
#
connections.
class
UrlConfig
<
DatabaseConfig
attr_reader
:url
,
:config
...
...
@@ -42,14 +42,14 @@ def url_config? # :nodoc:
end
# Determines whether a database configuration is for a replica / readonly
# connection. If the
`replica` key is present in the config, `replica?`
will
# connection. If the
+replica+ key is present in the config, +replica?+
will
# return +true+.
def
replica?
config
[
"replica"
]
end
# The migrations paths for a database configuration. If the
#
`migrations_paths` key is present in the config, `migrations_paths`
#
+migrations_paths+ key is present in the config, +migrations_paths+
# will return its value.
def
migrations_paths
config
[
"migrations_paths"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录