Created
November 25, 2010 19:35
-
-
Save mtrudel/715815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def record_purchase(customer, basket) | |
| basket.each do |product| | |
| product.buyers << customer | |
| end | |
| # Render these into the relation map -- this can be done out of process too | |
| basket.each do |x| | |
| all_products.each do |y| | |
| intersection[x][y] = x.buyers.intersect(y.buyers).count | |
| end | |
| end | |
| end | |
| def get_related_products(product) | |
| return intersection[product].sort | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment