Class: Gitlab::Git::User
- Inherits:
-
Object
- Object
- Gitlab::Git::User
- Defined in:
- lib/gitlab/git/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#gl_id ⇒ Object
readonly
Returns the value of attribute gl_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(username, name, email, gl_id, timezone) ⇒ User
constructor
A new instance of User.
- #to_gitaly ⇒ Object
Constructor Details
#initialize(username, name, email, gl_id, timezone) ⇒ User
Returns a new instance of User.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/git/user.rb', line 22 def initialize(username, name, email, gl_id, timezone) @username = username @name = name @email = email @gl_id = gl_id @timezone = if Feature.enabled?(:add_timezone_to_web_operations) timezone else Time.zone.tzinfo.name end end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
6 7 8 |
# File 'lib/gitlab/git/user.rb', line 6 def email @email end |
#gl_id ⇒ Object (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 |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/gitlab/git/user.rb', line 6 def name @name end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
6 7 8 |
# File 'lib/gitlab/git/user.rb', line 6 def timezone @timezone end |
#username ⇒ Object (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 20 |
# 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, gitaly_user.timezone ) end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 |
# File 'lib/gitlab/git/user.rb', line 35 def ==(other) [username, name, email, gl_id, timezone] == [other.username, other.name, other.email, other.gl_id, other.timezone] end |
#to_gitaly ⇒ Object
39 40 41 |
# File 'lib/gitlab/git/user.rb', line 39 def to_gitaly Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name.b, email: email.b, timezone: timezone) end |