{"action":"created","comment":{"url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/comments/43470472","id":43470472,"diff_hunk":"@@ -63,11 +63,16 @@ def harvest_and_index(each_options = { in_threads: 4 })\n     end\n \n     def resources\n-      druids.map do |x|\n-        Harvestdor::Indexer::Resource.new(self, x)\n-      end.map do |x|\n-        [x, (x.items if x.collection?)]\n-      end.flatten.uniq.compact\n+      return to_enum(:resources) unless block_given?\n+\n+      druids.each do |x|\n+        resource = Harvestdor::Indexer::Resource.new(self, x)\n+        yield resource\n+\n+        resource.items.each do |member|\n+          yield member\n+        end if resource.collection?\n+      end","path":"lib/harvestdor/indexer.rb","position":18,"original_position":18,"commit_id":"c74d415a6d131fe998463eda00208bbe9c410586","original_commit_id":"c74d415a6d131fe998463eda00208bbe9c410586","user":{"login":"ndushay","id":96775,"avatar_url":"https://avatars.githubusercontent.com/u/96775?v=3","gravatar_id":"","url":"https://api.github.com/users/ndushay","html_url":"https://github.com/ndushay","followers_url":"https://api.github.com/users/ndushay/followers","following_url":"https://api.github.com/users/ndushay/following{/other_user}","gists_url":"https://api.github.com/users/ndushay/gists{/gist_id}","starred_url":"https://api.github.com/users/ndushay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndushay/subscriptions","organizations_url":"https://api.github.com/users/ndushay/orgs","repos_url":"https://api.github.com/users/ndushay/repos","events_url":"https://api.github.com/users/ndushay/events{/privacy}","received_events_url":"https://api.github.com/users/ndushay/received_events","type":"User","site_admin":false},"body":"I guess I'm wondering if it might read something like this  (and i freely admit I'm not skilled at yields and procs and lambdas and passing blocks around):\r\n```ruby\r\n# return an enumerable collection of resources which includes each single item in the druids list, \r\n#   and all the items belonging to each collection id in druids.\r\ndef resource\r\n  return to_enum(:resources) unless block_given?\r\n\r\n  druids.each do |id|\r\n    # create a resource if it's an item \r\n    resource = Harvestdor::Indexer::Resource.new(self, id)\r\n    yield resource\r\n\r\n   # fetch item ids if it's a collection, and include those items in returned enum\r\n   resource.items.each do |member|\r\n    yield member\r\n  end if resource.collection?\r\nend\r\n\r\n```","created_at":"2015-10-30T04:13:51Z","updated_at":"2015-10-30T04:13:51Z","html_url":"https://github.com/sul-dlss/harvestdor-indexer/pull/18#discussion_r43470472","pull_request_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/comments/43470472"},"html":{"href":"https://github.com/sul-dlss/harvestdor-indexer/pull/18#discussion_r43470472"},"pull_request":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18","id":49215688,"html_url":"https://github.com/sul-dlss/harvestdor-indexer/pull/18","diff_url":"https://github.com/sul-dlss/harvestdor-indexer/pull/18.diff","patch_url":"https://github.com/sul-dlss/harvestdor-indexer/pull/18.patch","issue_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/18","number":18,"state":"open","locked":false,"title":"Harvestdor #resources and #items should be enumerable to work well with large collections","user":{"login":"cbeer","id":111218,"avatar_url":"https://avatars.githubusercontent.com/u/111218?v=3","gravatar_id":"","url":"https://api.github.com/users/cbeer","html_url":"https://github.com/cbeer","followers_url":"https://api.github.com/users/cbeer/followers","following_url":"https://api.github.com/users/cbeer/following{/other_user}","gists_url":"https://api.github.com/users/cbeer/gists{/gist_id}","starred_url":"https://api.github.com/users/cbeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbeer/subscriptions","organizations_url":"https://api.github.com/users/cbeer/orgs","repos_url":"https://api.github.com/users/cbeer/repos","events_url":"https://api.github.com/users/cbeer/events{/privacy}","received_events_url":"https://api.github.com/users/cbeer/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-29T23:47:28Z","updated_at":"2015-10-30T04:13:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"061bb095dcf9db4b71a4dfade22e532af4afd6f2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18/commits","review_comments_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18/comments","review_comment_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/18/comments","statuses_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/statuses/c74d415a6d131fe998463eda00208bbe9c410586","head":{"label":"sul-dlss:resources-enum","ref":"resources-enum","sha":"c74d415a6d131fe998463eda00208bbe9c410586","user":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars.githubusercontent.com/u/230583?v=3","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"repo":{"id":19285766,"name":"harvestdor-indexer","full_name":"sul-dlss/harvestdor-indexer","owner":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars.githubusercontent.com/u/230583?v=3","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sul-dlss/harvestdor-indexer","description":" Gem to harvest meta/data from Stanford DOR and the skeleton code to index it and write to Solr.","fork":false,"url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer","forks_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/forks","keys_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/teams","hooks_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/hooks","issue_events_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/events{/number}","events_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/events","assignees_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/assignees{/user}","branches_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/branches{/branch}","tags_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/tags","blobs_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/refs{/sha}","trees_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/statuses/{sha}","languages_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/languages","stargazers_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/stargazers","contributors_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/contributors","subscribers_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/subscribers","subscription_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/subscription","commits_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/commits{/sha}","git_commits_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/commits{/sha}","comments_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/comments{/number}","issue_comment_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/comments{/number}","contents_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/contents/{+path}","compare_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/merges","archive_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/downloads","issues_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues{/number}","pulls_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls{/number}","milestones_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/milestones{/number}","notifications_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/labels{/name}","releases_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/releases{/id}","created_at":"2014-04-29T17:43:54Z","updated_at":"2015-10-22T01:42:55Z","pushed_at":"2015-10-29T23:47:28Z","git_url":"git://github.com/sul-dlss/harvestdor-indexer.git","ssh_url":"git@github.com:sul-dlss/harvestdor-indexer.git","clone_url":"https://github.com/sul-dlss/harvestdor-indexer.git","svn_url":"https://github.com/sul-dlss/harvestdor-indexer","homepage":"","size":514,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"sul-dlss:master","ref":"master","sha":"92caaf1a8bbbe426ba1950e32a5b64c810134544","user":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars.githubusercontent.com/u/230583?v=3","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"repo":{"id":19285766,"name":"harvestdor-indexer","full_name":"sul-dlss/harvestdor-indexer","owner":{"login":"sul-dlss","id":230583,"avatar_url":"https://avatars.githubusercontent.com/u/230583?v=3","gravatar_id":"","url":"https://api.github.com/users/sul-dlss","html_url":"https://github.com/sul-dlss","followers_url":"https://api.github.com/users/sul-dlss/followers","following_url":"https://api.github.com/users/sul-dlss/following{/other_user}","gists_url":"https://api.github.com/users/sul-dlss/gists{/gist_id}","starred_url":"https://api.github.com/users/sul-dlss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sul-dlss/subscriptions","organizations_url":"https://api.github.com/users/sul-dlss/orgs","repos_url":"https://api.github.com/users/sul-dlss/repos","events_url":"https://api.github.com/users/sul-dlss/events{/privacy}","received_events_url":"https://api.github.com/users/sul-dlss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sul-dlss/harvestdor-indexer","description":" Gem to harvest meta/data from Stanford DOR and the skeleton code to index it and write to Solr.","fork":false,"url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer","forks_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/forks","keys_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/teams","hooks_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/hooks","issue_events_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/events{/number}","events_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/events","assignees_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/assignees{/user}","branches_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/branches{/branch}","tags_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/tags","blobs_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/refs{/sha}","trees_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/statuses/{sha}","languages_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/languages","stargazers_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/stargazers","contributors_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/contributors","subscribers_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/subscribers","subscription_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/subscription","commits_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/commits{/sha}","git_commits_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/git/commits{/sha}","comments_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/comments{/number}","issue_comment_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/comments{/number}","contents_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/contents/{+path}","compare_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/merges","archive_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/downloads","issues_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues{/number}","pulls_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls{/number}","milestones_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/milestones{/number}","notifications_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/labels{/name}","releases_url":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/releases{/id}","created_at":"2014-04-29T17:43:54Z","updated_at":"2015-10-22T01:42:55Z","pushed_at":"2015-10-29T23:47:28Z","git_url":"git://github.com/sul-dlss/harvestdor-indexer.git","ssh_url":"git@github.com:sul-dlss/harvestdor-indexer.git","clone_url":"https://github.com/sul-dlss/harvestdor-indexer.git","svn_url":"https://github.com/sul-dlss/harvestdor-indexer","homepage":"","size":514,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18"},"html":{"href":"https://github.com/sul-dlss/harvestdor-indexer/pull/18"},"issue":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/18"},"comments":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/sul-dlss/harvestdor-indexer/statuses/c74d415a6d131fe998463eda00208bbe9c410586"}}}}