Class: KakaxiParse::User
Constant Summary
collapse
- @@related_to =
[Role]
Constants inherited
from BaseModel
BaseModel::DEFUALT_LIMIT
Instance Attribute Summary collapse
Attributes inherited from BaseModel
#created_at, #id, #name, #updated_at
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseModel
all, #delete, demodulize, find, order
Constructor Details
#initialize(id: nil, name: nil, email: nil, password: nil, updated_at: nil, created_at: nil) ⇒ User
Returns a new instance of User.
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/kakaxi_parse/user.rb', line 6
def initialize(
id: nil,
name: nil,
email: nil,
password: nil,
updated_at: nil,
created_at: nil
)
@email = email
@password = password
super(id, name, updated_at, created_at)
end
|
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
3
4
5
|
# File 'lib/kakaxi_parse/user.rb', line 3
def email
@email
end
|
#password ⇒ Object
Returns the value of attribute password.
3
4
5
|
# File 'lib/kakaxi_parse/user.rb', line 3
def password
@password
end
|
Class Method Details
.name ⇒ Object
23
24
25
|
# File 'lib/kakaxi_parse/user.rb', line 23
def self.name
'_User'
end
|
.reference_name ⇒ Object
31
32
33
|
# File 'lib/kakaxi_parse/user.rb', line 31
def self.reference_name
'users'
end
|
.short_name ⇒ Object
27
28
29
|
# File 'lib/kakaxi_parse/user.rb', line 27
def self.short_name
'farmer'
end
|
.where(hash, limit: DEFUALT_LIMIT) ⇒ Object
19
20
21
|
# File 'lib/kakaxi_parse/user.rb', line 19
def self.where(hash, limit: DEFUALT_LIMIT)
to_objects(super(self, name_to_nickname(hash), limit, [], @@related_to)) if valid_key?(hash)
end
|
Instance Method Details
#farms ⇒ Object
53
54
55
|
# File 'lib/kakaxi_parse/user.rb', line 53
def farms
Farm.where(farmer_id: id)
end
|
#save ⇒ Object
39
40
41
|
# File 'lib/kakaxi_parse/user.rb', line 39
def save
id ? false : super(self, { nickname: name, email: email, password: password, username: email })
end
|
#sign_in ⇒ Object
35
36
37
|
# File 'lib/kakaxi_parse/user.rb', line 35
def sign_in
API.new('login', params: {username: email, password: password}).get
end
|
#update(params) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/kakaxi_parse/user.rb', line 43
def update(params)
original_params = build_original_params(params)
if super(self, User.name_to_nickname(params))
original_params.each { |key, value| self.send("#{key}=", value) }
true
else
false
end
end
|