类:Mongoid::Generators::ConfigGenerator
- 继承:
-
Rails::Generators::Base
- 对象
- Rails::Generators::Base
- Mongoid::Generators::ConfigGenerator
- 定义于:
- lib/rails/generators/mongoid/config/config_generator.rb
Overview
Mongoid 配置文件的生成器类。
类方法摘要折叠
-
。 source_root ⇒ string
返回模板目录的路径。
实例方法摘要折叠
-
# app_name ⇒ string
返回 Rails应用程序的带下划线的名称。
-
# create_config_file ⇒ 对象
从模板创建
mongoid.yml
配置文件。 -
# create_initializer_file ⇒ 对象
从模板创建
mongoid.rb
初始化程序文件。
类方法详细信息
。 source_root ⇒ string
返回模板目录的路径。
18 19 20 |
# File 'lib/rails/generators/mongoid/config/config_generator.rb', line 18 def self.source_root @_mongoid_source_root ||= file.(" ../templates ", __FILE__) end |
实例方法详细信息
# app_name ⇒ string
返回 Rails应用程序的带下划线的名称。
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails/generators/mongoid/config/config_generator.rb', line 25 def app_name # :nodoc: app_cls = Rails.应用程序.class 父项 = 开始 # Rails 6.1 + app_cls.module_parent_name 救援 NoMethodError app_cls.父项.to_s end 父项.下划线 end |
# create_config_file ⇒对象
从模板创建mongoid.yml
配置文件。
37 38 39 |
# File 'lib/rails/generators/mongoid/config/config_generator.rb', line 37 def create_config_file template 'mongoid.yml', file.连接 (JOIN)('config', 'mongoid.yml') end |
# create_initializer_file ⇒对象
从模板创建mongoid.rb
初始化程序文件。
42 43 44 |
# File 'lib/rails/generators/mongoid/config/config_generator.rb', line 42 def create_initializer_file template ' mongoid.rb ', file.连接 (JOIN)('config', ' initializers ', ' mongoid.rb ') end |