Sha256: a53cfa31bcc3d91fe84e483f11d2196a1de7b8232c0b365a7f38a0bf1c09761a
Contents?: true
Size: 657 Bytes
Versions: 1
Compression:
Stored size: 657 Bytes
Contents
require 'active_support' class LHS::Service module All extend ActiveSupport::Concern module ClassMethods def all(params = {}) all = [] data = instance.request(params: params.merge(limit: 100)) all.concat(data._raw['items']) total_left = data._raw['total'] - data.count limit = data._raw['limit'] || data.count requests = total_left / limit requests.times do |i| offset = limit * (i+1) + 1 all.concat instance.request(params: params.merge(limit: limit, offset: offset))._raw['items'] end LHS::Data.new(all, nil, self) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lhs-1.2.0 | lib/lhs/concerns/service/all.rb |