Class: ItemsForSalePopulator

Inherits:
Object
  • Object
show all
Includes:
ThreadsPerSlice
Defined in:
lib/discogs/wishlist/populators/items_for_sale_populator.rb

Instance Method Summary collapse

Methods included from ThreadsPerSlice

#threads_per_slice

Constructor Details

#initialize(wishlist:) ⇒ ItemsForSalePopulator

Returns a new instance of ItemsForSalePopulator.



11
12
13
14
15
# File 'lib/discogs/wishlist/populators/items_for_sale_populator.rb', line 11

def initialize(wishlist:)
  @wishlist = wishlist

  configure_money
end

Instance Method Details

#populate!Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/discogs/wishlist/populators/items_for_sale_populator.rb', line 17

def populate!
  threads_per_slice(wishlist, 2) do |slice, mutex|
    slice.each do |wishlist_album|
      wishlist_album.variations.each do |variation|
        mutex.synchronize do
          variation.add_items_for_sale(find_items_for_sale(variation.id))
        end
      end
    end
  end
end