Created
March 3, 2014 20:31
-
-
Save dhh/9333991 to your computer and use it in GitHub Desktop.
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
class GroupersController < ApplicationController::Base | |
def create | |
@grouper = Grouper.new(leader: current_member) | |
if @grouper.save | |
ConfirmedGrouperEmails.new(@grouper).deliver | |
AssignBarForGrouper.enqueue(@grouper.id) | |
redirect_to home_path | |
else | |
render :new | |
end | |
end | |
end | |
# app/mailers/confirmed_grouper_emails.rb | |
class ConfirmedGrouperEmails | |
def initialize(grouper) | |
@grouper = grouper | |
end | |
def deliver | |
LeaderMailer.grouper_confirmed(member: @grouper.leader.id).deliver | |
WingMailer.grouper_confirmed(wings: @grouper.wings.pluck(:id)).deliver | |
AdminMailer.grouper_confirmed(grouper: @grouper.admin.id).deliver | |
end | |
end |
@shime 👍
Put another way, passing the argument to a class method is not "exemplary" (a la Sandi Metz). So future development efforts (often by other devs) are likely harmed, since this pattern resists refactoring.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Class methods resist refactoring.