Sha256: 116f5b5713b808e7eb0844563ac996c190d7cba620dbb71024f558299a0efbd8

Contents?: true

Size: 791 Bytes

Versions: 27

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/mongoid_generator'

module Mongoid
  module Generators
    class ConfigGenerator < Rails::Generators::Base
      desc "Creates a Mongoid configuration file at config/mongoid.yml"

      argument :database_name, type: :string, optional: true

      def self.source_root
        @_mongoid_source_root ||= File.expand_path("../templates", __FILE__)
      end

      def app_name
        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

      def create_config_file
        template 'mongoid.yml', File.join('config', "mongoid.yml")
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
mongoid-8.1.9 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.9 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.8 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.7 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.6 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.8 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.5 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.4 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.7 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.3 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.2 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.6 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-7.5.4 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.1 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.5 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.1.0 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-7.5.3 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.4 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-8.0.3 lib/rails/generators/mongoid/config/config_generator.rb
mongoid-7.5.2 lib/rails/generators/mongoid/config/config_generator.rb