Sha256: 991403768358076eebec05ec43cdf660f854921cb68681467a77e5a21c1ffe0f

Contents?: true

Size: 494 Bytes

Versions: 8

Compression:

Stored size: 494 Bytes

Contents

class NationBuilder::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 self.class.new(@client, results)
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nationbuilder-rb-1.3.4 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.3.3 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.3.2 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.3.1 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.3.0 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.2.3 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.2.2 lib/nationbuilder/paginator.rb
nationbuilder-rb-1.2.1 lib/nationbuilder/paginator.rb