Skip to content

Instantly share code, notes, and snippets.

@mikebaldry
Created May 6, 2011 11:25
Show Gist options
  • Select an option

  • Save mikebaldry/958780 to your computer and use it in GitHub Desktop.

Select an option

Save mikebaldry/958780 to your computer and use it in GitHub Desktop.
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