Sha256: 4dab310fa56c1b9f367120e85fbfa78c6ae4f46ff7c1701549fd415e40e0e169

Contents?: true

Size: 984 Bytes

Versions: 2

Compression:

Stored size: 984 Bytes

Contents

require 'rails/generators/migration'

module AuthN
  module Generators
    class ConfigGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path('../templates', __FILE__)

      class_option :model, model_option_options

      # Copy the initializer file to config/initializers folder.
      def copy_initializer_file
        template "initializer.rb", "config/initializers/authn.rb"
      end

      private

      # Either return the model passed in a classified form or return the default "Account".
      def model_class_name
        options[:model] ? options[:model].classify : "Account"
      end

      def model_option_options
        {
          optional: true,
          type: :string,
          banner: "model",
          desc: model_option_description
        }
      end

      def model_option_description
        "Define the name of your default 'User' class. Default Value: Account"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authn-rails-1.7.3 lib/generators/authn/install_generator.rb
authn-rails-1.7.2 lib/generators/authn/install_generator.rb