Sha256: dbca821199e74cc0775f8d362148311b789ba4403c55a15f047a7d46a64bfd22

Contents?: true

Size: 490 Bytes

Versions: 1

Compression:

Stored size: 490 Bytes

Contents

require "ostruct"

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

    def initialize(page)
      @page = page
      @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.6 lib/laziness/pager.rb