Files
grecia/app/components/polls/results/question_component.rb
Javi Martín 8997ed316c Rename variables describing poll options as answers
Since we've renamed the class to `Option`, having variables, methods and
texts refering to it as `answer` was confusing.
2024-06-13 19:13:05 +02:00

16 lines
313 B
Ruby

class Polls::Results::QuestionComponent < ApplicationComponent
attr_reader :question
def initialize(question:)
@question = question
end
def option_styles(option)
"win" if most_voted_option?(option)
end
def most_voted_option?(option)
option.id == question.most_voted_option_id
end
end