gab-social/app/services/vote_service.rb
2020-11-15 12:48:32 -06:00

24 lines
477 B
Ruby

# frozen_string_literal: true
class VoteService < BaseService
include Authorization
def call(account, poll, choices)
authorize_with account, poll, :vote?
@account = account
@poll = poll
@choices = choices
@votes = []
ApplicationRecord.transaction do
@choices.each do |choice|
@votes << @poll.votes.create!(account: @account, choice: choice)
end
end
ActivityTracker.increment('activity:interactions')
end
end