Sha256: 1660f5380d3e77f82c6c7a72d5a9f5051a24586219d4a48711f533e1d1d4b784

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

require 'forwardable'

module Harvesting
  module Models
    class HarvestRecordCollection < Base
      include Harvesting::Enumerable
      extend Forwardable

      attributed :per_page,
                 :total_pages,
                 :total_entries,
                 :next_page,
                 :previous_page,
                 :page,
                 :links

      attr_reader :entries

      def initialize(attrs, query_opts = {}, opts = {})
        super(attrs, opts)
        @query_opts = query_opts
        @api_page = attrs
      end

      def page
        @attributes['page']
      end

      def size
        total_entries
      end

      def next_page_query_opts
        @query_opts.merge(page: page + 1)
      end

      def fetch_next_page
        raise NotImplementedError
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
harvesting-0.6.0 lib/harvesting/models/harvest_record_collection.rb
harvesting-0.5.1 lib/harvesting/models/harvest_record_collection.rb
harvesting-0.5.0 lib/harvesting/models/harvest_record_collection.rb
harvesting-0.4.0 lib/harvesting/models/harvest_record_collection.rb