Class: Repositories::BranchNamesFinder
- Inherits:
-
Object
- Object
- Repositories::BranchNamesFinder
- Defined in:
- app/finders/repositories/branch_names_finder.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(repository, params = {}) ⇒ BranchNamesFinder
constructor
A new instance of BranchNamesFinder.
Constructor Details
#initialize(repository, params = {}) ⇒ BranchNamesFinder
Returns a new instance of BranchNamesFinder.
7 8 9 10 |
# File 'app/finders/repositories/branch_names_finder.rb', line 7 def initialize(repository, params = {}) @repository = repository @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'app/finders/repositories/branch_names_finder.rb', line 5 def params @params end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
5 6 7 |
# File 'app/finders/repositories/branch_names_finder.rb', line 5 def repository @repository end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/finders/repositories/branch_names_finder.rb', line 12 def execute return unless search && offset && limit default_branch = repository.root_ref all_branch_names = repository.search_branch_names(search).sort.lazy.to_a deleted_branch = all_branch_names.delete(default_branch) all_branch_names.unshift(deleted_branch) if deleted_branch all_branch_names.drop(offset).take(limit) # rubocop:disable CodeReuse/ActiveRecord -- Results returned from redis not database end |