Skip to content

Commit

Permalink
Extract Class Step Two
Browse files Browse the repository at this point in the history
* Move one method to the new class
  • Loading branch information
jferris committed Feb 14, 2013
1 parent cce3348 commit ac01475
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example_app/app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def new

def create
@survey = Survey.find(params[:survey_id])
@survey_inviter = SurveyInviter.new
@survey_inviter = SurveyInviter.new(recipients)
if valid_recipients? && valid_message?
recipient_list.each do |email|
invitation = Invitation.create(
Expand Down Expand Up @@ -45,7 +45,7 @@ def invalid_recipients
end

def recipient_list
@recipient_list ||= recipients.gsub(/\s+/, '').split(/[\n,;]+/)
@survey_inviter.recipient_list
end

def recipients
Expand Down
7 changes: 7 additions & 0 deletions example_app/app/models/survey_inviter.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
class SurveyInviter
def initialize(recipients)
@recipients = recipients
end

def recipient_list
@recipient_list ||= @recipients.gsub(/\s+/, '').split(/[\n,;]+/)
end
end

0 comments on commit ac01475

Please sign in to comment.