class ActiveGraph::Paginated

Attributes

current_page[R]
items[R]
total[R]

Public Class Methods

create_from(source, page, per_page, order = nil) click to toggle source
   # File lib/active_graph/paginated.rb
12 def self.create_from(source, page, per_page, order = nil)
13   target = source.node_var || source.identity
14   partial = source.skip((page - 1) * per_page).limit(per_page)
15   ordered_partial, ordered_source = if order
16                                       [partial.order_by(order), source.query.with("#{target} as #{target}").pluck("COUNT(#{target})").first]
17                                     else
18                                       [partial, source.count]
19                                     end
20   Paginated.new(ordered_partial, ordered_source, page)
21 end
new(items, total, current_page) click to toggle source
   # File lib/active_graph/paginated.rb
 6 def initialize(items, total, current_page)
 7   @items = items
 8   @total = total
 9   @current_page = current_page
10 end