Class: Ish::UserProfile
Overview
It explicitly doesn’t have a relation to user! Use email as key.
Constant Summary
collapse
- ROLES =
[ :guy, :manager, :admin ]
- ROLE_GUY =
:guy
- ROLE_MANAGER =
:manager
- ROLE_ADMIN =
:admin
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#export
#unvote, #vote, #vote_value, #voted?, #votees
Class Method Details
.generate(delta) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/ish/user_profile.rb', line 84
def self.generate delta
email = delta[:email]
password = delta[:password]
role_name = delta[:role_name]
profile = Ish::UserProfile.where( email: email ).first
if profile
return
end
user = User.where( email: email ).first
if !user
user = User.new({ email: email, password: password })
end
profile = Ish::UserProfile.new({
email: email,
role_name: role_name,
})
profile.save
if profile.persisted?
;
else
puts! profile.errors.full_messages, "Cannot save profile"
end
end
|
.list ⇒ Object
61
62
63
64
|
# File 'lib/ish/user_profile.rb', line 61
def self.list
out = self.all
[['', nil]] + out.map { |item| [ item.email, item.id ] }
end
|
.list_lg ⇒ Object
65
66
67
68
|
# File 'lib/ish/user_profile.rb', line 65
def self.list_lg
out = self.all
[['', nil]] + out.map { |item| [ "#{item.email} :: #{item.name}", item.id ] }
end
|
Instance Method Details
#export_fields ⇒ Object
23
24
25
26
27
28
|
# File 'lib/ish/user_profile.rb', line 23
def export_fields
%w|
email
role_name
|
end
|
#has_premium_purchase(item) ⇒ Object
74
75
76
|
# File 'lib/ish/user_profile.rb', line 74
def has_premium_purchase item
payments.confirmed.where( item: item ).exists?
end
|