<commit_before>require 'rails/generators'
module MongoidForums
  module Generators
    class InstallGenerator < Rails::Generators::Base
      class_option "user-class", :type => :string
      class_option "current-user-helper", :type => :string

      source_root File.expand_path("../install/templates", __FILE__)
      desc "Used to install MongoidForums"

      def determine_user_class
        # Is there a cleaner way to do this?
        if options["user-class"]
          puts "Class of item passed as argument #{options["user-class"].class}"
          @user_class = options["user-class"]
        else
          @user_class = ask("What is your user class called? [User]")
          puts "Class of item passed from prompt #{@user_class.class}"
        end

        if @user_class.blank?
          @user_class = 'User'
          puts "Class of item set when blank #{@user_class.class}"
        else
          @user_class = @user_class
          puts "Class of item set when passed #{@user_class.class}"
        end

        MongoidForums.decorate_user_class!
        puts "Decorating user class!"
      end


      def determine_current_user_helper
        if options["current-user-helper"]
          current_user_helper = options["current-user-helper"]
        else
          current_user_helper = ask("What is the current_user helper called in your app? [current_user]")
        end
        current_user_helper = :current_user if current_user_helper.blank?
        puts "Defining mongoid_forums_user method inside ApplicationController..."

        mongoid_forums_user_method = %Q{
  def mongoid_forums_user
    #{current_user_helper}
  end
  helper_method :mongoid_forums_user
}

        inject_into_file("#{Rails.root}/app/controllers/application_controller.rb",<commit_msg>Stop forcing user class decoration in install generator<commit_after>require 'rails/generators'
module MongoidForums
  module Generators
    class InstallGenerator < Rails::Generators::Base
      class_option "user-class", :type => :string
      class_option "current-user-helper", :type => :string

      source_root File.expand_path("../install/templates", __FILE__)
      desc "Used to install MongoidForums"

      def determine_user_class
        # Is there a cleaner way to do this?
        if options["user-class"]
          puts "Class of item passed as argument #{options["user-class"].class}"
          @user_class = options["user-class"]
        else
          @user_class = ask("What is your user class called? [User]")
          puts "Class of item passed from prompt #{@user_class.class}"
        end

        if @user_class.blank?
          @user_class = 'User'
          puts "Class of item set when blank #{@user_class.class}"
        else
          @user_class = @user_class
          puts "Class of item set when passed #{@user_class.class}"
        end
      end


      def determine_current_user_helper
        if options["current-user-helper"]
          current_user_helper = options["current-user-helper"]
        else
          current_user_helper = ask("What is the current_user helper called in your app? [current_user]")
        end
        current_user_helper = :current_user if current_user_helper.blank?
        puts "Defining mongoid_forums_user method inside ApplicationController..."

        mongoid_forums_user_method = %Q{
  def mongoid_forums_user
    #{current_user_helper}
  end
  helper_method :mongoid_forums_user
}

        inject_into_file("#{Rails.root}/app/controllers/application_controller.rb",
{'fraction_non_alphanumeric': 0.08938706015891033, 'fraction_numerical': 0.0, 'mean_word_length': 2.810810810810811, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2135212', 'n_tokens_mistral': 992, 'n_tokens_neox': 983, 'n_words': 267}