summaryrefslogtreecommitdiff
path: root/lib/bitbucket/collection.rb
blob: 3a9379ff680b6e89531d72f1104167a7f40b4a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Bitbucket
  class Collection < Enumerator
    def initialize(paginator)
      super() do |yielder|
        loop do
          paginator.items.each { |item| yielder << item }
        end
      end

      lazy
    end

    def method_missing(method, *args)
      return super unless self.respond_to?(method)

      self.send(method, *args) do |item|
        block_given? ? yield(item) : item
      end
    end
  end
end