Sha256: b35668d5f55722c1e31a31200cf2dc9674b235e670a7494e944348ee1b84c0bc

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

require "ostruct"

module Slack
  class Pager
    attr_reader :cursor, :limit, :page

    def initialize(page)
      @page = page.dup
      @limit = @page[:limit] unless empty?
    end

    def empty?
      page.nil? || page.empty?
    end

    def to_h
      { cursor: cursor, limit: limit }
    end

    def next(cursor)
      self.class.new(page).tap do |pager|
        pager.cursor = cursor
      end
    end

    protected

    def cursor=(cursor)
      @cursor = cursor
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
laziness-0.2.5 lib/laziness/pager.rb