Skip to content

Commit

Permalink
Refactor finders. Prevent circular dependency error
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <[email protected]>
  • Loading branch information
dzaporozhets committed Sep 2, 2014
1 parent 9ccef9a commit 20c2e90
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/finders/base_finder.rb → app/finders/issuable_finder.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BaseFinder
# IssuableFinder
#
# Used to filter Issues and MergeRequests collections by set of params
#
Expand All @@ -16,7 +16,9 @@
# label_name: string
# sort: string
#
class BaseFinder
require_relative 'projects_finder'

class IssuableFinder
attr_accessor :current_user, :params

def execute(current_user, params)
Expand Down
2 changes: 1 addition & 1 deletion app/finders/issues_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# label_name: string
# sort: string
#
class IssuesFinder < BaseFinder
class IssuesFinder < IssuableFinder
def klass
Issue
end
Expand Down
2 changes: 1 addition & 1 deletion app/finders/merge_requests_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# label_name: string
# sort: string
#
class MergeRequestsFinder < BaseFinder
class MergeRequestsFinder < IssuableFinder
def klass
MergeRequest
end
Expand Down
6 changes: 3 additions & 3 deletions lib/api/issues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class Issues < Grape::API
helpers do
def filter_issues_state(issues, state = nil)
case state
when 'opened' then issues.opened
when 'closed' then issues.closed
else issues
when 'opened' then issues.opened
when 'closed' then issues.closed
else issues
end
end
end
Expand Down

0 comments on commit 20c2e90

Please sign in to comment.