Class: AccountUser
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AccountUser
show all
- Includes:
- ActiveUUID::UUID
- Defined in:
- app/models/account_user.rb
Instance Method Summary
collapse
#fix_uuid_strings, included
Instance Method Details
#_destroy ⇒ Object
15
|
# File 'app/models/account_user.rb', line 15
alias :_destroy :destroy
|
#add_default_roles ⇒ Object
33
34
35
36
|
# File 'app/models/account_user.rb', line 33
def add_default_roles
roles.create( { :name => APP_ROLES[ "owner_role" ] } )
roles.create( { :name => APP_ROLES[ "admin_role" ] } ) if APP_ROLES[ "owner_role" ] != APP_ROLES[ "admin_role" ]
end
|
#cancel_destruction ⇒ Object
28
29
30
|
# File 'app/models/account_user.rb', line 28
def cancel_destruction
destruction_job.try(:destroy) unless destruction_job.try(:locked_at)
end
|
#destroy ⇒ Object
16
17
18
|
# File 'app/models/account_user.rb', line 16
def destroy
Delayed::Job.enqueue DestroyAccountUserJob.new(id.to_s), :queue => "account_user_#{id}_destroy", :run_at => DateTime.now + IuguSDK::delay_account_user_exclusion
end
|
#destroying? ⇒ Boolean
24
25
26
|
# File 'app/models/account_user.rb', line 24
def destroying?
!!destruction_job
end
|
#destruction_job ⇒ Object
20
21
22
|
# File 'app/models/account_user.rb', line 20
def destruction_job
Delayed::Job.find_by_queue("account_user_#{id}_destroy")
end
|
#is?(role) ⇒ Boolean
60
61
62
63
64
|
# File 'app/models/account_user.rb', line 60
def is?(role)
role = APP_ROLES[ "owner_role" ] if role.to_s == "owner"
role = APP_ROLES[ "admin_role" ] if role.to_s == "admin"
roles.exists?(:name => role)
end
|
#set_owner ⇒ Object
55
56
57
58
|
# File 'app/models/account_user.rb', line 55
def set_owner
roles.create name: "owner"
reload
end
|
#set_roles(new_roles) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/models/account_user.rb', line 38
def set_roles(new_roles)
if new_roles.nil?
roles.destroy_all
else
valid = true
new_roles.each do |new_role|
valid = false unless APP_ROLES['roles'].include? new_role
end
return false unless valid
roles.destroy_all
new_roles.each do |new_role|
roles.create( :name => new_role )
end
end
true
end
|