Created
May 6, 2011 11:25
-
-
Save mikebaldry/958780 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 self.by_id(id) | |
| cached_supplier = @suppliers.find { |s| s.db_id == id } | |
| return cached_supplier if cached_supplier | |
| supplier = from_row(DB[:supplier].filter(:supplier_id => id).first) | |
| @suppliers << supplier | |
| supplier | |
| end | |
| def self.all | |
| return @suppliers unless @suppliers.empty? | |
| @suppliers = DB[:supplier].all.collect { |s| from_row s } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment