File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,25 @@ class Survey < ActiveRecord::Base
1111
1212 def summaries_using ( summarizer , options = { } )
1313 questions . map do |question |
14- if !options [ :answered_by ] || question . answered_by? ( options [ :answered_by ] )
15- question . summary_using ( summarizer )
16- else
17- Summary . new ( question . title , NO_ANSWER )
18- end
14+ summary_or_hidden_answer ( summarizer , question , options [ :answered_by ] )
1915 end
2016 end
17+
18+ private
19+
20+ def summary_or_hidden_answer ( summarizer , question , answered_by )
21+ if hide_unanswered_question? ( question , answered_by )
22+ hide_answer_to_question ( question )
23+ else
24+ question . summary_using ( summarizer )
25+ end
26+ end
27+
28+ def hide_unanswered_question? ( question , answered_by )
29+ answered_by && !question . answered_by? ( answered_by )
30+ end
31+
32+ def hide_answer_to_question ( question )
33+ Summary . new ( question . title , NO_ANSWER )
34+ end
2135end
You can’t perform that action at this time.
0 commit comments