Class: ShopPackagesDataset

Inherits:
Dataset::Base
  • Object
show all
Defined in:
app/datasets/shop_packages.rb

Instance Method Summary collapse

Instance Method Details

#loadObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/datasets/shop_packages.rb', line 5

def load
  packages = {
    :bread  => [ :soft, :crusty, :warm ]
  }
  
  packages.each do |package, products|
    create_record :shop_package, "all_#{package.to_s}".to_sym,
      :name     => "all #{package.to_s}",
      :sku      => "all_#{package.to_s}",
      :price    => 1 * 10
    products.each_with_index do |product, i|
      create_record :shop_packing, "#{product.to_s}_bread".to_s.to_sym,
        :quantity => 1,
        :position => 1,
        :package  => shop_packages("all_#{package.to_s}".to_sym),
        :product  => shop_products("#{product.to_s}_bread".to_sym)
    end
  end
end