Class: MembersFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/members_finder.rb

Constant Summary collapse

RELATIONS =
%i(direct inherited descendants invited_groups).freeze
DEFAULT_RELATIONS =
%i(direct inherited).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, current_user, params: {}) ⇒ MembersFinder

Returns a new instance of MembersFinder.


12
13
14
15
16
17
# File 'app/finders/members_finder.rb', line 12

def initialize(project, current_user, params: {})
  @project = project
  @group = project.group
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Params can be any of the following:

sort:       string
search:     string

10
11
12
# File 'app/finders/members_finder.rb', line 10

def params
  @params
end

Instance Method Details

#can?(*args) ⇒ Boolean

Returns:

  • (Boolean)

25
26
27
# File 'app/finders/members_finder.rb', line 25

def can?(*args)
  Ability.allowed?(*args)
end

#execute(include_relations: DEFAULT_RELATIONS) ⇒ Object


19
20
21
22
23
# File 'app/finders/members_finder.rb', line 19

def execute(include_relations: DEFAULT_RELATIONS)
  members = find_members(include_relations)

  filter_members(members)
end