Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class ArticlesQuery
  2. TEXT_LENGTH = 3
  3.  
  4. def initialize(comments = Comment.all)
  5. @comments = comments
  6. end
  7.  
  8. def all
  9. comments
  10. .where("user_id IS NOT NULL")
  11. .where("LENGTH(content) #{condition}")
  12. end
  13.  
  14. def condition
  15. "> #{TEXT_LENGTH}"
  16. end
  17. end
  18.  
  19. class LongArticlesQuery < ArticlesQuery
  20. TEXT_LENGTH = 5
  21.  
  22. def condition
  23. ">= #{TEXT_LENGTH}"
  24. end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement