Class: Namespaces::Groups::SharedGroupsFinder

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Allowable, Namespaces::GroupsFilter
Defined in:
app/finders/namespaces/groups/shared_groups_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(group, current_user = nil, params = {}) ⇒ SharedGroupsFinder

Returns a new instance of SharedGroupsFinder.



22
23
24
25
26
# File 'app/finders/namespaces/groups/shared_groups_finder.rb', line 22

def initialize(group, current_user = nil, params = {})
  @group = group
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



20
21
22
# File 'app/finders/namespaces/groups/shared_groups_finder.rb', line 20

def current_user
  @current_user
end

#groupObject (readonly)

Returns the value of attribute group.



20
21
22
# File 'app/finders/namespaces/groups/shared_groups_finder.rb', line 20

def group
  @group
end

#paramsObject (readonly)

Returns the value of attribute params.



20
21
22
# File 'app/finders/namespaces/groups/shared_groups_finder.rb', line 20

def params
  @params
end

Instance Method Details

#executeObject



28
29
30
31
32
33
34
# File 'app/finders/namespaces/groups/shared_groups_finder.rb', line 28

def execute
  return Group.none unless can?(current_user, :read_group, group)

  groups = group.shared_groups.public_or_visible_to_user(current_user)
  groups = filter_shared_groups(groups)
  sort(groups).with_route
end