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
Constant Summary
collapse
- NON_ADMIN_ROLES =
['editor', 'account_manager']
- ROLES =
NON_ADMIN_ROLES + ['admin']
Instance Method Summary
collapse
#active_for_authentication?, #suspend!, #suspended?, #unsuspend!
Instance Method Details
#account_manager? ⇒ Boolean
32
33
34
|
# File 'lib/pageflow/user_mixin.rb', line 32
def account_manager?
role == 'account_manager'
end
|
#admin? ⇒ Boolean
28
29
30
|
# File 'lib/pageflow/user_mixin.rb', line 28
def admin?
role == '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
self.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
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
|