module Rails::Generators::ModelHelpers

def self.included(base) # :nodoc:

:nodoc:
def self.included(base) # :nodoc:
  base.class_option :force_plural, type: :boolean, default: false, desc: "Forces the use of the given model name"
end

def inflection_impossible?(name)

def inflection_impossible?(name)
  name != name.underscore &&
    name.singularize.underscore != name.pluralize.underscore.singularize
end

def initialize(args, *_options)

def initialize(args, *_options)
  super
  if plural_model_name?(name) && !options[:force_plural]
    singular = name.singularize
    unless ModelHelpers.skip_warn
      say PLURAL_MODEL_NAME_WARN_MESSAGE % [name, singular]
    end
    name.replace singular
    assign_names!(name)
  end
  if inflection_impossible?(name)
    option1 = name.singularize.underscore
    option2 = name.pluralize.underscore.singularize
    raise Error, INFLECTION_IMPOSSIBLE_ERROR_MESSAGE % [name, option1, option2]
  end
  if irregular_model_name?(name) && ! ModelHelpers.skip_warn
    say IRREGULAR_MODEL_NAME_WARN_MESSAGE % [name.pluralize]
  end
  ModelHelpers.skip_warn = true
end

def irregular_model_name?(name)

def irregular_model_name?(name)
  name.singularize != name.pluralize.singularize
end

def plural_model_name?(name)

def plural_model_name?(name)
  name == name.pluralize && name.singularize != name.pluralize
end