Created
February 11, 2011 12:29
-
-
Save roy/822276 to your computer and use it in GitHub Desktop.
To code smell, or not to code smell: that is the question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# old | |
def build_form_response | |
form_response = self.form_responses.new | |
self.questions.each do |question| | |
form_response.answers.build(:question => question) | |
end | |
form_response | |
end | |
# using tap | |
def build_form_response | |
self.form_responses.new.tap do |form_response| | |
self.questions.each do |question| | |
form_response.answers.build(:question => question) | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:)