-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring getRecentProfiles method
- Loading branch information
1 parent
e54f2a9
commit 90603f5
Showing
7 changed files
with
84 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
class SearchCriteria | ||
attr_reader :query, :tag, :order | ||
attr_reader :query, :tag, :order_by | ||
|
||
def initialize(query, tag = nil, order = nil) | ||
def initialize(query, tag: nil, order_by: nil, sort_direction: "DESC") | ||
@query = query | ||
@tag = tag | ||
@order = order | ||
@order_by = order_by | ||
@sort_direction = sort_direction | ||
end | ||
|
||
def valid? | ||
!query.nil? && query != 0 | ||
end | ||
|
||
def sort_direction | ||
sanitize_direction(@sort_direction) | ||
end | ||
|
||
private | ||
|
||
def sanitize_direction(direction) | ||
if direction.present? | ||
direction = direction.upcase | ||
options = ['DESC', 'ASC'] | ||
options.include?(direction) ? direction : "DESC" | ||
else | ||
"DESC" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters