Class: Five9::User
- Inherits:
-
Object
show all
- Defined in:
- lib/five9/user.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(args) ⇒ User
Returns a new instance of User.
4
5
6
7
8
9
|
# File 'lib/five9/user.rb', line 4
def initialize(args)
@user_info = args.make_accessible
@general_info = @user_info[:general_info].make_accessible
@roles = @user_info[:roles].make_accessible
@skills = SkillArray.new(args[:skills])
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
45
46
47
|
# File 'lib/five9/user.rb', line 45
def method_missing(method_name, *args)
@general_info.send(method_name, *args)
end
|
Instance Attribute Details
#general_info ⇒ Object
Returns the value of attribute general_info.
3
4
5
|
# File 'lib/five9/user.rb', line 3
def general_info
@general_info
end
|
#roles ⇒ Object
Returns the value of attribute roles.
3
4
5
|
# File 'lib/five9/user.rb', line 3
def roles
@roles
end
|
#skills ⇒ Object
Returns the value of attribute skills.
3
4
5
|
# File 'lib/five9/user.rb', line 3
def skills
@skills
end
|
Class Method Details
.exist?(username) ⇒ Boolean
.where(args) ⇒ Object
67
68
69
70
71
|
# File 'lib/five9/user.rb', line 67
def self.where(args)
all.keep_if do |user|
user.merge(args).to_hash == user.to_hash
end
end
|
Instance Method Details
#save ⇒ Object
18
19
20
21
22
|
# File 'lib/five9/user.rb', line 18
def save
UserManagement.modify_user(build_modify_hash)
@skills.update!
self
end
|
#to_h ⇒ Object
11
12
13
14
15
16
|
# File 'lib/five9/user.rb', line 11
def to_h
@user_info[:general_info] = @general_info
@user_info[:roles] = @roles
@user_info[:skills] = @skills.to_a
@user_info
end
|
#update(args) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/five9/user.rb', line 28
def update(args)
if args[:general_info]
@user_info = to_h.merge(args)
@general_info = @user_info[:general_info].make_accessible
@roles = @user_info[:roles].make_accessible
@skills = SkillArray.new(args[:skills])
@user_info
else
merge! args
end
end
|
#update!(args) ⇒ Object
40
41
42
43
|
# File 'lib/five9/user.rb', line 40
def update!(args)
update args
save
end
|