Skip to content

Commit d5b4871

Browse files
committed
Refactor: extract method Question#score_for_answer
* First step towards Move Method
1 parent e6895ad commit d5b4871

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

example_app/app/models/completion.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def answers_attributes=(answers_attributes)
1515

1616
def score
1717
answers.inject(0) do |result, answer|
18-
question = answer.question
19-
result + question.score(answer.text)
18+
result + score_for_answer(answer)
2019
end
2120
end
2221

@@ -25,4 +24,9 @@ def score
2524
def completion_notification
2625
Mailer.completion_notification(user).deliver
2726
end
27+
28+
def score_for_answer(answer)
29+
question = answer.question
30+
question.score(answer.text)
31+
end
2832
end

0 commit comments

Comments
 (0)