Class: Lobby::PasswordForgottenFormAbstract
- Inherits:
-
Object
- Object
- Lobby::PasswordForgottenFormAbstract
show all
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/lobby/password_forgotten_form_abstract.rb
Constant Summary
collapse
- USER_CLASS =
"User"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PasswordForgottenFormAbstract.
20
21
22
|
# File 'app/models/lobby/password_forgotten_form_abstract.rb', line 20
def initialize(token)
@token = token
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
39
40
41
42
43
44
45
|
# File 'app/models/lobby/password_forgotten_form_abstract.rb', line 39
def method_missing(m, *args, &block)
if m == self.user_class.name.downcase.to_sym
send("user_object")
else
super
end
end
|
Instance Attribute Details
#new_password ⇒ Object
Returns the value of attribute new_password.
5
6
7
|
# File 'app/models/lobby/password_forgotten_form_abstract.rb', line 5
def new_password
@new_password
end
|
Instance Method Details
#submit(params) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/lobby/password_forgotten_form_abstract.rb', line 24
def submit(params)
self.new_password = params[:new_password]
self.new_password_confirmation = params[:new_password_confirmation]
if valid?
user_object.password = new_password
user_object.password_confirmation = new_password_confirmation
user_object.password_token = nil
user_object.save!
true
else
false
end
end
|
#user_class ⇒ Object
12
13
14
|
# File 'app/models/lobby/password_forgotten_form_abstract.rb', line 12
def user_class
proc{ self.class::USER_CLASS.constantize}.call
end
|
#user_object ⇒ Object
16
17
18
|
# File 'app/models/lobby/password_forgotten_form_abstract.rb', line 16
def user_object
@user_object ||= (@token.present?)? user_class.where(password_token: @token).first : nil
end
|