Module: WillPaginate::DataMapper::CollectionMethods

### Home Classes Methods

### In Files

- lib/will_paginate/data_mapper.rb

### Methods

- #offset
- #paginated?
- #per_page
- #to_a
- #total_entries

### Included Modules

- WillPaginate::CollectionMethods

### Class/Module Index

Quicksearch

- WillPaginate
- WillPaginate::ActionView
- WillPaginate::ActionView::LinkRenderer
- WillPaginate::ActiveRecord
- WillPaginate::ActiveRecord::BaseMethods
- WillPaginate::ActiveRecord::Pagination
- WillPaginate::ActiveRecord::RelationMethods
- WillPaginate::Collection
- WillPaginate::CollectionMethods
- WillPaginate::DataMapper
- WillPaginate::DataMapper::CollectionMethods
- WillPaginate::DataMapper::Pagination
- WillPaginate::Deprecation
- WillPaginate::Deprecation::Hash
- WillPaginate::I18n
- WillPaginate::InvalidPage
- WillPaginate::Merb
- WillPaginate::Merb::LinkRenderer
- WillPaginate::PageNumber
- WillPaginate::PerPage
- WillPaginate::PerPage::Inheritance
- WillPaginate::Railtie
- WillPaginate::Railtie::ControllerRescuePatch
- WillPaginate::Railtie::ShowExceptionsPatch
- WillPaginate::SequelMethods
- WillPaginate::Sinatra
- WillPaginate::Sinatra::Helpers
- WillPaginate::Sinatra::LinkRenderer
- WillPaginate::ViewHelpers
- WillPaginate::ViewHelpers::LinkRenderer
- WillPaginate::ViewHelpers::LinkRendererBase
- Array
- Object

No matching classes.

# WillPaginate::DataMapper::CollectionMethods

### Attributes

current_page[RW]

### Public Instance Methods

offset() click to toggle source

    # File lib/will_paginate/data_mapper.rb, line 45
    def offset
      query.offset
    end

paginated?() click to toggle source

    # File lib/will_paginate/data_mapper.rb, line 37
    def paginated?
      !current_page.nil?
    end

per_page() click to toggle source

    # File lib/will_paginate/data_mapper.rb, line 41
    def per_page
      query.limit || model.per_page
    end

to_a() click to toggle source

    # File lib/will_paginate/data_mapper.rb, line 65
    def to_a
      if paginated?
        ::WillPaginate::Collection.create(current_page, per_page) do |col|
          col.replace super
          col.total_entries ||= total_entries
        end
      else
        super
      end
    end

total_entries() click to toggle source

    # File lib/will_paginate/data_mapper.rb, line 49
    def total_entries
      @total_entries ||= begin
        if loaded? and @array.size < per_page and (current_page == 1 or @array.size > 0)
          offset + @array.size
        else
          # :reload prevents Collection.filter from being run, which
          # would cause a stack overflow
          clean_query = query.merge(:reload => true)
          # seems like the only way
          clean_query.instance_variable_set('@limit', nil)
          clean_query.instance_variable_set('@offset', 0)
          new_collection(clean_query).count
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.