Sha256: 36983ec1e21ab72d060f1ba291a13a7b1f5764630b4d0c6c9ad7171ca744a88a

Contents?: true

Size: 478 Bytes

Versions: 2

Compression:

Stored size: 478 Bytes

Contents

class Paginator
  attr_reader :body

  def initialize(client, body)
    @client = client
    @body = body
  end

  [:next, :prev].each do |page_type|
    define_method(:"#{page_type}?") do
      @body[page_type.to_s]
    end

    define_method(:"#{page_type}") do
      return nil unless send(:"#{page_type}?")
      path = send(:"#{page_type}?").split('/api/v1').last
      results = @client.raw_call(path, :get)
      return Paginator.new(@client, results)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nationbuilder-rb-1.2.0 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.1.0 lib/nationbuilder/paginator.rb