debian-mirror-gitlab/app/finders/repositories/branch_names_finder.rb
2021-06-08 01:23:25 +05:30

32 lines
580 B
Ruby

# frozen_string_literal: true
module Repositories
class BranchNamesFinder
attr_reader :repository, :params
def initialize(repository, params = {})
@repository = repository
@params = params
end
def execute
return unless search && offset && limit
repository.search_branch_names(search).lazy.drop(offset).take(limit) # rubocop:disable CodeReuse/ActiveRecord
end
private
def search
@params[:search].presence
end
def offset
@params[:offset]
end
def limit
@params[:limit]
end
end
end