Sha256: b2f77a809437454e4ba70b06ac415b2dfa650ea6f25021ca595ede9c5c65a804

Contents?: true

Size: 693 Bytes

Versions: 17

Compression:

Stored size: 693 Bytes

Contents

require 'active_scaffold/paginator'

class Paginator

  # Total number of pages
  def number_of_pages_with_infinite
    number_of_pages_without_infinite if @count
  end
  alias_method_chain :number_of_pages, :infinite
  
  # Is this an "infinite" paginator
  def infinite?
    @count.nil?
  end

  def count
    @count || first.items.size
  end
  
  class Page
    # Checks to see if there's a page after this one
    def next_with_infinite?
      return true if @pager.infinite?
      next_without_infinite?
    end
    alias_method_chain :next?, :infinite

    def empty?
      if @pager.infinite?
        items.to_a.empty?
      else
        @pager.count == 0
      end
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
active_scaffold-3.4.17 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.16 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.14 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.13 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.12 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.11 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.10 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.9 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.8 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.7 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.5 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.4 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.3 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.2 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.1 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.0.1 lib/active_scaffold/extensions/paginator_extensions.rb
active_scaffold-3.4.0 lib/active_scaffold/extensions/paginator_extensions.rb