Class: Mongoid::Generators::ConfigGenerator
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Rails::Generators::Base
|
|
Instance Chain:
self,
Rails::Generators::Base
|
|
Inherits: |
Rails::Generators::Base
|
Defined in: | lib/rails/generators/mongoid/config/config_generator.rb |
Overview
Generator class for ::Mongoid
configuration files.
Class Method Summary
-
.source_root ⇒ String
Returns the path to the templates directory.
Instance Method Summary
-
#app_name ⇒ String
Returns the underscored name of the
::Rails
application. -
#create_config_file
Creates a
mongoid.yml
config file from a template. -
#create_initializer_file
Creates a
mongoid.rb
initializer file from a template.
Class Method Details
.source_root ⇒ String
Returns the path to the templates directory.
# File 'lib/rails/generators/mongoid/config/config_generator.rb', line 18
def self.source_root @_mongoid_source_root ||= File. ("../templates", __FILE__) end
Instance Method Details
#app_name ⇒ String
Returns the underscored name of the ::Rails
application.
# File 'lib/rails/generators/mongoid/config/config_generator.rb', line 25
def app_name # :nodoc: app_cls = Rails.application.class parent = begin # Rails 6.1+ app_cls.module_parent_name rescue NoMethodError app_cls.parent.to_s end parent.underscore end
#create_config_file
Creates a mongoid.yml
config file from a template.
# 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
Creates a mongoid.rb
initializer file from a template.
# 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