Created
November 23, 2009 17:40
-
-
Save avand/241220 to your computer and use it in GitHub Desktop.
This file contains 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
# Given a set of class names, will require objects of those types to have been populated | |
# Usage: depends_on(User, Post, Comment) | |
def depends_on(*args) | |
raise "Depends on #{args.map{ |a| a.name.pluralize }.to_sentence.downcase} to populate data." if args.any? { |a| a.count.zero? } | |
args.each { |a| eval "@#{a.name.underscore.pluralize} = #{a}.all" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment