Module: TinyBuilder::ModeExecutor

Included in:
TinyBuilder
Defined in:
lib/tiny_builder/mode_executor.rb

Instance Method Summary collapse

Instance Method Details

#builder_classesObject



14
15
16
17
18
19
20
# File 'lib/tiny_builder/mode_executor.rb', line 14

def builder_classes
  {
    quantity: TinyBuilder::QuantityBuilder,
    price: TinyBuilder::PriceBuilder,
    active: TinyBuilder::ActiveBuilder
  }
end

#collect_listingsObject



26
27
28
29
30
31
32
# File 'lib/tiny_builder/mode_executor.rb', line 26

def collect_listings
  data = []
  MongoVariantListing.in(icava_id: listing_ids).each do |listing|
    data << listing
  end
  data
end

#listingsObject



22
23
24
# File 'lib/tiny_builder/mode_executor.rb', line 22

def listings
  @listings ||= collect_listings
end

#perform_builderObject



5
6
7
8
9
10
11
12
# File 'lib/tiny_builder/mode_executor.rb', line 5

def perform_builder
  builder_classes[mode].new(
    listings: listings,
    mwh: mwh,
    channel_id: credential['channel_id'],
    inventory_v2: credential['inventory_v2']
  ).perform
end

#prepare_dataObject



34
35
36
37
38
39
40
41
42
# File 'lib/tiny_builder/mode_executor.rb', line 34

def prepare_data
  if credential['channel_id'] == 13
    TinyBuilder::ZaloraQuantity.new(credential, listings).perform
  elsif credential['channel_id'] == 2
    TinyBuilder::ShopifyQuantity.new(credential, listings).perform
  elsif credential['channel_id'] == 19
    TinyBuilder::WoocommerceQuantity.new(credential, listings).perform
  end
end