debian-mirror-gitlab/app/finders/README.md

23 lines
467 B
Markdown
Raw Normal View History

2014-09-02 18:07:02 +05:30
# Finders
2015-04-26 12:48:37 +05:30
This type of classes responsible for collection items based on different conditions.
To prevent lookup methods in models like this:
2014-09-02 18:07:02 +05:30
```ruby
class Project
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)
```
2015-04-26 12:48:37 +05:30
Better use this:
2014-09-02 18:07:02 +05:30
```ruby
2015-09-11 14:41:01 +05:30
issues = IssuesFinder.new(project, user, filter).execute
2014-09-02 18:07:02 +05:30
```
2015-04-26 12:48:37 +05:30
It will help keep models thiner.