Guest User

Untitled

a guest
Apr 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. # Given a set of class names, will require objects of those types to have been populated
  2. # Usage: depends_on(User, Post, Comment)
  3. def depends_on(*args)
  4. raise "Depends on #{args.map{ |a| a.name.pluralize }.to_sentence.downcase} to populate data." if args.any? { |a| a.count.zero? }
  5. args.each { |a| eval "@#{a.name.underscore.pluralize} = #{a}.all" }
  6. end
Add Comment
Please, Sign In to add comment