Class: Gitlab::Audit::NullAuthor

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/audit/null_author.rb

Direct Known Subclasses

DeletedAuthor, UnauthenticatedAuthor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:) ⇒ NullAuthor

Returns a new instance of NullAuthor.


26
27
28
29
# File 'lib/gitlab/audit/null_author.rb', line 26

def initialize(id:, name:)
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


6
7
8
# File 'lib/gitlab/audit/null_author.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name


6
7
8
# File 'lib/gitlab/audit/null_author.rb', line 6

def name
  @name
end

Class Method Details

.for(id, name) ⇒ Gitlab::Audit::UnauthenticatedAuthor, Gitlab::Audit::DeletedAuthor

Creates an Author

While tracking events that could take place even when a user is not logged in, (eg: downloading repo of a public project), we set the author_id of such events as -1

Parameters:

  • id (Integer)
  • name (String)

Returns:


18
19
20
21
22
23
24
# File 'lib/gitlab/audit/null_author.rb', line 18

def self.for(id, name)
  if id == -1
    Gitlab::Audit::UnauthenticatedAuthor.new(name: name)
  else
    Gitlab::Audit::DeletedAuthor.new(id: id, name: name)
  end
end

Instance Method Details

#current_sign_in_ipObject


31
32
33
# File 'lib/gitlab/audit/null_author.rb', line 31

def 
  nil
end