# frozen_string_literal: true
module Kaminari
  module Mongoid
    module MongoidCriteriaMethods
      def initialize_copy(other) #:nodoc:
        @total_count = nil
        super
      end

      def entry_name
        model_name.human.downcase
      end

      def limit_value #:nodoc:
        options[:limit]
      end

      def offset_value #:nodoc:
        options[:skip]
      end

      def total_count #:nodoc:
        @total_count ||= if embedded?
          unpage.size
        elsif options[:max_scan] && options[:max_scan] < size
          options[:max_scan]
        else
          size
        end
      end

      private
      def unpage
        clone.tap do |crit|
          crit.options.delete :limit
          crit.options.delete :skip
        end
      end
    end
  end
end

# frozen_string_literal: true
module Kaminari
  module Mongoid
    module MongoidCriteriaMethods
      def initialize_copy(other) #:nodoc:
        @total_count = nil
        super
      end

      def entry_name(options = {})
        model_name.human(options.reverse_merge(default: model_name.human.pluralize(options[:count])))
      end

      def limit_value #:nodoc:
        options[:limit]
      end

      def offset_value #:nodoc:
        options[:skip]
      end

      def total_count #:nodoc:
        @total_count ||= if embedded?
          unpage.size
        elsif options[:max_scan] && options[:max_scan] < size
          options[:max_scan]
        else
          size
        end
      end

      private
      def unpage
        clone.tap do |crit|
          crit.options.delete :limit
          crit.options.delete :skip
        end
      end
    end
  end
end

Use I18n to pluralize entries
Use I18n to pluralize entries

see: https://github.com/amatsuda/kaminari/commit/7f6e9a877d646263dc0504a5ad96ef4d5f2dd684
