debian-mirror-gitlab/app/finders/README.md
2021-01-03 14:25:43 +05:30

531 B

Finders

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

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:

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

It will help keep models thinner.