Class: Neo4j::ActiveNode::Query::QueryProxy

Inherits:
Object
  • Object
show all
Includes:
WillPaginate::CollectionMethods
Defined in:
lib/neo4j-will_paginate_redux.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



37
38
39
# File 'lib/neo4j-will_paginate_redux.rb', line 37

def page
  @page
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



37
38
39
# File 'lib/neo4j-will_paginate_redux.rb', line 37

def per_page
  @per_page
end

#result_orderObject (readonly)

Returns the value of attribute result_order.



37
38
39
# File 'lib/neo4j-will_paginate_redux.rb', line 37

def result_order
  @result_order
end

#returnsObject (readonly)

Returns the value of attribute returns.



37
38
39
# File 'lib/neo4j-will_paginate_redux.rb', line 37

def returns
  @returns
end

Instance Method Details

#paginate(options = {}) ⇒ Object

Paginates the Enumerable and returns WillPaginate::Collection instance.

Examples:

Paginate on a relationship:

person.friends.paginate(:page => 5, :per_page => 10)

Paginate the search results:

Person.all(:conditions => "name: Dmytrii*").paginate(:page => 5, :per_page => 10)

Parameters:

  • options (Hash) (defaults to: {})

    a hash of options for the pagination.

Options Hash (options):

  • :page (Symbol)

    current page for the pagination (defualts to 1).

  • :per_page (Symbol)

    numer of items per page (defaults to WillPaginate.per_page). Aliases are ‘:per`, `:limit`.

  • :return (String, Array)

    an optional string or array of identifiers used earlier in the query requested for return.

  • :order (String, Symbol)

    an optional QueryProxy ‘order` clause to sort your results



29
30
31
32
33
34
35
# File 'lib/neo4j-will_paginate_redux.rb', line 29

def paginate(options={})
  @page         = (options[:page] || 1).to_i
  @per_page     = (options[:per] || options[:per_page] || options[:limit] || ::WillPaginate.per_page).to_i
  @result_order = options[:order]
  @returns      = to_return(options[:return])
  ::WillPaginate::Collection.create(page, per_page) { |pager| pager_return(pager) }
end