Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArticlesQuery
- TEXT_LENGTH = 3
- def initialize(comments = Comment.all)
- @comments = comments
- end
- def all
- comments
- .where("user_id IS NOT NULL")
- .where("LENGTH(content) #{condition}")
- end
- def condition
- "> #{TEXT_LENGTH}"
- end
- end
- class LongArticlesQuery < ArticlesQuery
- TEXT_LENGTH = 5
- def condition
- ">= #{TEXT_LENGTH}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement