Class: Searls::Auth::UpdatesSettings
- Inherits:
-
Object
- Object
- Searls::Auth::UpdatesSettings
- Defined in:
- lib/searls/auth/updates_settings.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(user:, params:) ⇒ UpdatesSettings
constructor
A new instance of UpdatesSettings.
- #update ⇒ Object
Constructor Details
#initialize(user:, params:) ⇒ UpdatesSettings
Returns a new instance of UpdatesSettings.
12 13 14 15 16 17 |
# File 'lib/searls/auth/updates_settings.rb', line 12 def initialize(user:, params:) @user = user @params = params || {} @errors = [] @password_changed = false end |
Instance Method Details
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/searls/auth/updates_settings.rb', line 19 def update enforce_current_password_requirement handle_password_change if errors.empty? return failure_result unless errors.empty? if changes_applied? if user.save Result.new( success?: true, user: user, errors: [], password_changed?: @password_changed ) else Result.new( success?: false, user: user, errors: (user) ) end else Result.new(success?: true, user: user, errors: [], password_changed?: false) end end |