summaryrefslogtreecommitdiff
path: root/app/finders/README.md
blob: 52f7378c4844a5e6979f4b7932333aa68435de45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Finders

These types of classes are responsible for retrieving collection items based on different conditions.
They prevent lookup methods in models like this:


```ruby
class Project < ApplicationRecord
  def issues_for_user_filtered_by(user, filter)
    # A lot of logic not related to project model itself
  end
end

issues = project.issues_for_user_filtered_by(user, params)
```

The GitLab approach is to use a Finder:

```ruby
issues = IssuesFinder.new(project, user, filter).execute
```

It will help keep models thinner.