Class: Gitlab::Git::User

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/git/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, name, email, gl_id) ⇒ User

Returns a new instance of User.


21
22
23
24
25
26
# File 'lib/gitlab/git/user.rb', line 21

def initialize(username, name, email, gl_id)
  @username = username
  @name = name
  @email = email
  @gl_id = gl_id
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email


6
7
8
# File 'lib/gitlab/git/user.rb', line 6

def email
  @email
end

#gl_idObject (readonly)

Returns the value of attribute gl_id


6
7
8
# File 'lib/gitlab/git/user.rb', line 6

def gl_id
  @gl_id
end

#nameObject (readonly)

Returns the value of attribute name


6
7
8
# File 'lib/gitlab/git/user.rb', line 6

def name
  @name
end

#usernameObject (readonly)

Returns the value of attribute username


6
7
8
# File 'lib/gitlab/git/user.rb', line 6

def username
  @username
end

Class Method Details

.from_gitaly(gitaly_user) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/gitlab/git/user.rb', line 12

def self.from_gitaly(gitaly_user)
  new(
    gitaly_user.gl_username,
    Gitlab::EncodingHelper.encode!(gitaly_user.name),
    Gitlab::EncodingHelper.encode!(gitaly_user.email),
    gitaly_user.gl_id
  )
end

.from_gitlab(gitlab_user) ⇒ Object


8
9
10
# File 'lib/gitlab/git/user.rb', line 8

def self.from_gitlab(gitlab_user)
  new(gitlab_user.username, gitlab_user.name, gitlab_user.commit_email, Gitlab::GlId.gl_id(gitlab_user))
end

Instance Method Details

#==(other) ⇒ Object


28
29
30
# File 'lib/gitlab/git/user.rb', line 28

def ==(other)
  [username, name, email, gl_id] == [other.username, other.name, other.email, other.gl_id]
end

#to_gitalyObject


32
33
34
# File 'lib/gitlab/git/user.rb', line 32

def to_gitaly
  Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name.b, email: email.b)
end