Class: YouTrack::Client::User

Inherits:
Model
  • Object
show all
Defined in:
lib/you_track/client/models/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

ms_time, #require_admin!

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



17
18
19
# File 'lib/you_track/client/models/user.rb', line 17

def password
  @password
end

#usernameObject

Returns the value of attribute username.



17
18
19
# File 'lib/you_track/client/models/user.rb', line 17

def username
  @username
end

Instance Method Details

#admin?Boolean

just try to make a request to the admin api and see what happens

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/you_track/client/models/user.rb', line 10

def admin? # just try to make a request to the admin api and see what happens
  return @admin if defined?(@admin) # i love how ||= doesn't work when a variable is false
  @admin = !!service.get_admin_user(self.id).body
rescue Faraday::ResourceNotFound
  @admin = false
end

#saveObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/you_track/client/models/user.rb', line 19

def save
  if new_record?
    requires :username, :email

    service.create_user(
      "email"    => self.email,
      "fullName" => self.name,
      "jabber"   => self.jabber,
      "login"    => self.username,
      "password" => self.password,
    )

    merge_attributes(
      :identity => self.username,
    )
  else
    raise NotImplementedError
  end
end