Class: UserManager::Update
- Inherits:
-
Object
- Object
- UserManager::Update
- Defined in:
- app/my_lib/user_manager/update.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(user) ⇒ Update
constructor
A new instance of Update.
- #set_user_attributes(valid_params) ⇒ Object
- #update ⇒ Object
Constructor Details
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'app/my_lib/user_manager/update.rb', line 5 def user @user end |
Instance Method Details
#error_message ⇒ Object
39 40 41 |
# File 'app/my_lib/user_manager/update.rb', line 39 def user.errors..uniq.to_sentence end |
#set_user_attributes(valid_params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/my_lib/user_manager/update.rb', line 15 def set_user_attributes(valid_params) if valid_params[:r_code].present? if user.r_code.present? valid_params.delete(:r_code) end end if valid_params[:phone_v2].present? && user.phone_v2_full.present? valid_params[:phone] = nil end user.assign_attributes valid_params end |
#update ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/my_lib/user_manager/update.rb', line 27 def update if user.changed? if user.save true else false end else true end end |