Class: AwardEmojis::CollectUserEmojiService
- Inherits:
-
Object
- Object
- AwardEmojis::CollectUserEmojiService
- Defined in:
- app/services/award_emojis/collect_user_emoji_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user = nil) ⇒ CollectUserEmojiService
constructor
current_user - The User to generate the data for.
Constructor Details
#initialize(current_user = nil) ⇒ CollectUserEmojiService
current_user - The User to generate the data for.
9 10 11 |
# File 'app/services/award_emojis/collect_user_emoji_service.rb', line 9 def initialize(current_user = nil) @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/services/award_emojis/collect_user_emoji_service.rb', line 6 def current_user @current_user end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/services/award_emojis/collect_user_emoji_service.rb', line 13 def execute return [] unless current_user # We want the resulting data set to be an Array containing the emoji names # in descending order, based on how often they were awarded. AwardEmoji .award_counts_for_user(current_user) .map { |name, _| { name: name } } end |