Class: PollParticipationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/poll_participation_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ PollParticipationService

Returns a new instance of PollParticipationService.


4
5
6
# File 'app/services/poll_participation_service.rb', line 4

def initialize(user)
  @user = user
end

Instance Method Details

#vote(post_id, answer_id) ⇒ Object


8
9
10
11
# File 'app/services/poll_participation_service.rb', line 8

def vote(post_id, answer_id)
  answer = PollAnswer.find(answer_id)
  @user.participate_in_poll!(target(post_id), answer) if target(post_id)
end