Class: Gitlab::GithubImport::Importer::CollaboratorImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Importer::CollaboratorImporter
- Defined in:
- lib/gitlab/github_import/importer/collaborator_importer.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#collaborator ⇒ Object
readonly
Returns the value of attribute collaborator.
-
#members_finder ⇒ Object
readonly
Returns the value of attribute members_finder.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(collaborator, project, client) ⇒ CollaboratorImporter
constructor
collaborator - An instance of ‘Gitlab::GithubImport::Representation::Collaborator` project - An instance of `Project` client - An instance of `Gitlab::GithubImport::Client`.
Constructor Details
#initialize(collaborator, project, client) ⇒ CollaboratorImporter
collaborator - An instance of ‘Gitlab::GithubImport::Representation::Collaborator` project - An instance of `Project` client - An instance of `Gitlab::GithubImport::Client`
12 13 14 15 16 17 |
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 12 def initialize(collaborator, project, client) @collaborator = collaborator @project = project @client = client @members_finder = ::MembersFinder.new(project, project.creator) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7 def client @client end |
#collaborator ⇒ Object (readonly)
Returns the value of attribute collaborator.
7 8 9 |
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7 def collaborator @collaborator end |
#members_finder ⇒ Object (readonly)
Returns the value of attribute members_finder.
7 8 9 |
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7 def members_finder @members_finder end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7 def project @project end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 19 def execute user_finder = GithubImport::UserFinder.new(project, client) user_id = user_finder.user_id_for(collaborator) return if user_id.nil? access_level = map_access_level if user_finder.source_user_accepted?(collaborator) membership = existing_user_membership(user_id) return if membership && membership[:access_level] >= map_access_level create_membership!(user_id, access_level) else ::Import::PlaceholderMemberships::CreateService.new( source_user: user_finder.source_user(collaborator), access_level: access_level, project: project ).execute end end |