-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrecommend_quote.rb
30 lines (27 loc) · 1.26 KB
/
recommend_quote.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# app/interactors/recommend_quote.rb
class RecommendQuote
include Interactor
def call
user = context.user
show_different = context.show_different
recommend_strategy = if user.nil?
AnonymousRecommenderService.new(user)
else
case
when user.random?
RandomRecommenderService.new(user)
when user.content_based_category?
ContentBasedCategoryRecommenderService.new(user, show_different)
when user.global_popularity?
GlobalPopularityRecommenderService.new(user, show_different)
when user.content_based_quote_analysis?
ContentBasedQuoteAnalysisRecommenderService.new(user, show_different)
when user.content_based_mixed?
ContentBasedMixedRecommenderService.new(user, show_different)
else
AnonymousRecommenderService.new(user)
end
end
context.result = recommend_strategy.show_next
end
end