summaryrefslogtreecommitdiff
path: root/lib/bitbucket_server/collection.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-10 23:21:12 -0700
committerStan Hu <stanhu@gmail.com>2018-07-10 23:21:12 -0700
commitbb98ed112c509c6265ba4dff81d7987c52a8748c (patch)
treeb1d85b9821bf6b213744884923841840b4930a21 /lib/bitbucket_server/collection.rb
parent0936bff496a6e0a8615a56ddca6270e44202587a (diff)
downloadgitlab-ce-bb98ed112c509c6265ba4dff81d7987c52a8748c.tar.gz
Add missing file
Diffstat (limited to 'lib/bitbucket_server/collection.rb')
-rw-r--r--lib/bitbucket_server/collection.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/bitbucket_server/collection.rb b/lib/bitbucket_server/collection.rb
new file mode 100644
index 00000000000..1f199c99854
--- /dev/null
+++ b/lib/bitbucket_server/collection.rb
@@ -0,0 +1,21 @@
+module BitbucketServer
+ 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| # rubocop:disable GitlabSecurity/PublicSend
+ block_given? ? yield(item) : item
+ end
+ end
+ end
+end