class OperationTimeline::Collection
Adapter between the timeline and Pagy’s pagy helper. Pagy calls count then offset(n).limit(n); we return the already-paginated rows from the query.
Public Class Methods
Source
# File app/services/operation_timeline.rb, line 130 def initialize(timeline) @timeline = timeline end
Creates the adapter for a timeline.
@param timeline [OperationTimeline] the query to paginate
Public Instance Methods
Source
# File app/services/operation_timeline.rb, line 135 def count @timeline.count end
@return [Integer] the row count
Source
# File app/services/operation_timeline.rb, line 151 def limit(limit) @timeline.rows(limit: limit, offset: @offset.to_i) end
Fetches the page rows.
@param limit [Integer] the page size @return [Array<Hash>] the paginated rows
Source
# File app/services/operation_timeline.rb, line 142 def offset(offset) @offset = offset self end
Returns self with a pending offset (Pagy chains offset → limit).
@return [OperationTimeline::Collection] self