Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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
Add Comment
Please, Sign In to add comment