Class: MergeRequestTargetProjectFinder

Inherits:
Object
  • Object
show all
Includes:
FinderMethods
Defined in:
app/finders/merge_request_target_project_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FinderMethods

#find, #find_by, #find_by!

Constructor Details

#initialize(current_user: nil, source_project:) ⇒ MergeRequestTargetProjectFinder

Returns a new instance of MergeRequestTargetProjectFinder.


8
9
10
11
# File 'app/finders/merge_request_target_project_finder.rb', line 8

def initialize(current_user: nil, source_project:)
  @current_user = current_user
  @source_project = source_project
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


6
7
8
# File 'app/finders/merge_request_target_project_finder.rb', line 6

def current_user
  @current_user
end

#source_projectObject (readonly)

Returns the value of attribute source_project


6
7
8
# File 'app/finders/merge_request_target_project_finder.rb', line 6

def source_project
  @source_project
end

Instance Method Details

#execute(include_routes: false) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


14
15
16
17
18
19
20
# File 'app/finders/merge_request_target_project_finder.rb', line 14

def execute(include_routes: false)
  if source_project.fork_network
    include_routes ? projects.inc_routes : projects
  else
    Project.where(id: source_project)
  end
end