Module: BooticClient::EnumerableEntity
- Includes:
- Enumerable
- Defined in:
- lib/bootic_client/entity.rb
Instance Method Summary collapse
Instance Method Details
#each(&block) ⇒ Object
9 10 11 |
# File 'lib/bootic_client/entity.rb', line 9 def each(&block) self[:items].each &block end |
#full_set ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bootic_client/entity.rb', line 13 def full_set page = self Enumerator.new do |yielder| loop do page.each { |item| yielder.yield(item) } raise StopIteration unless page.has_rel?(:next) page = page.next if page.has?(:errors) # && page.errors.first.messages.first['cannot be higher'] # reached last page yielder.yield(nil, page.errors) # yield a nil value so caller can stop gracefully raise StopIteration end end end end |