Sha256: d2f5f07ab41caa2dabf34bc65245f9f26727e7d00b29e08d50bc7d086c4aa69a

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

class ShopProductsDataset < Dataset::Base  

  uses :shop_categories, :images

  def load
    categories = {
      :bread => [ :soft, :crusty, :warm ],
      :milk => [ :full, :hilo, :choc ]
    }
    
    categories.each do |category, products|
      products.each_with_index do |product, i|
        create_record :shop_product, "#{product.to_s}_#{category.to_s}".to_sym,
          :name     => "#{product.to_s} #{category.to_s}",
          :sku      => "#{product.to_s}_#{category.to_s}",
          :price    => i + 1 * 10,
          :position => i + 1,
          :weight   => i + 10 * 3,
          :category => shop_categories(category)
      end
    end
    
    shop_products(:soft_bread).images = [
      images(:soft_bread_front),
      images(:soft_bread_back),
      images(:soft_bread_top)
    ]
    
    shop_products(:crusty_bread).images << images(:crusty_bread_front)
    
    shop_products(:warm_bread).images << images(:warm_bread_front)
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-shop-extension-0.9.3 spec/datasets/shop_products.rb
radiant-shop-extension-0.9.2 spec/datasets/shop_products.rb