Module: Pageflow::UserMixin
- Extended by:
- ActiveSupport::Concern
- Includes:
- Suspendable
- Defined in:
- lib/pageflow/user_mixin.rb
Overview
ActiveRecord related functionality of the Pageflow users.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary
collapse
#active_for_authentication?, #suspend!, #suspended?, #unsuspend!
Instance Method Details
#admin? ⇒ Boolean
32
33
34
|
# File 'lib/pageflow/user_mixin.rb', line 32
def admin?
admin
end
|
#destroy_with_password(password) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/pageflow/user_mixin.rb', line 58
def destroy_with_password(password)
if valid_password?(password)
destroy
true
else
errors.add(:current_password, password.blank? ? :blank : :invalid)
false
end
end
|
40
41
42
|
# File 'lib/pageflow/user_mixin.rb', line 40
def formal_name
[last_name, first_name] * ', '
end
|
#full_name ⇒ Object
36
37
38
|
# File 'lib/pageflow/user_mixin.rb', line 36
def full_name
[first_name, last_name] * ' '
end
|
#locale ⇒ Object
44
45
46
|
# File 'lib/pageflow/user_mixin.rb', line 44
def locale
super.presence || I18n.default_locale.to_s
end
|
#send_devise_notification(notification, *args) ⇒ Object
Configure devise to send emails using ActiveJob.
69
70
71
|
# File 'lib/pageflow/user_mixin.rb', line 69
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end
|
#update_with_password(attributes) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/pageflow/user_mixin.rb', line 48
def update_with_password(attributes)
if needs_password?(attributes)
super(attributes)
else
update_without_password(attributes.except(:current_password))
end
end
|