Skip to content
Permalink
Browse files

Rename params -> attributes, makes more sense

  • Loading branch information
jasonroelofs committed Sep 10, 2012
1 parent 8ee1813 commit 3a942a83aeece200c7c40661ccbc1cec55d37e64
Showing with 16 additions and 16 deletions.
  1. +5 −5 app/interactors/sign_up_user.rb
  2. +11 −11 app/interactors/update_user.rb
@@ -5,13 +5,13 @@ class SignUpUser

attr_reader :user

def run(user_params)
@user = User.new :login => user_params[:login],
:email => user_params[:email],
:password => user_params[:password].presence
def run(attributes)
@user = User.new :login => attributes[:login],
:email => attributes[:email],
:password => attributes[:password].presence

if @user.valid?
if @user.password != user_params[:password_confirmation].presence
if @user.password != attributes[:password_confirmation].presence
@user.errors.add(:password, "does not match confirmation")
false
else
@@ -28,28 +28,28 @@ def user
# Should this object know about changing the password or should
# the use of ChangePassword be pulled out to the controller?
##
def run(params)
@current_user.login = params[:login] if params[:login].present?
@current_user.email = params[:email] if params[:email].present?
def run(attributes)
@current_user.login = attributes[:login] if attributes[:login].present?
@current_user.email = attributes[:email] if attributes[:email].present?

if password_change_requested?(params)
if password_change_requested?(attributes)
action = ChangePassword.new(@current_user)
@current_user = action.run *explode_password_params(params)
@current_user = action.run *explode_password_attributes(attributes)
end

Repository.for(User).save(@current_user)
end

protected

def password_change_requested?(params)
params[:current_password].present? &&
params[:new_password].present? &&
params[:confirm_new_password].present?
def password_change_requested?(attributes)
attributes[:current_password].present? &&
attributes[:new_password].present? &&
attributes[:confirm_new_password].present?
end

def explode_password_params(params)
params.values_at :current_password, :new_password, :confirm_new_password
def explode_password_attributes(attributes)
attributes.values_at :current_password, :new_password, :confirm_new_password
end

end

0 comments on commit 3a942a8

Please sign in to comment.
You can’t perform that action at this time.