Next, I’m going to work on refactoring Redmine’s controllers in order to make them match the REST pattern and to take advantage of Rail’s built in REST helpers. In order to do this though, I need to refactor how Redmine’s routes are setup. Since the routes.rb file is over 290 lines long, the first thing …
Tag: move-method
Daily Refactor #58: Move Method to Query Model
The Refactoring Using move method I was able to move a chunk of duplicated code from the QueriesController into the Query model. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # app/controllers/queries_controller.rb def new # ... params[:fields].each do |field| @query.add_filter(field, params[:operators][field], params[:values][field]) end if …
Daily Refactor #55: Move Pane Configuration To KanbanPane
The Refactoring I picked a big refactoring today. What started out as a small isolated change, grew and grew as I found dependencies all over the plugin. I used move method primarily but there are several other refactorings along for the ride. Before you get hit with the wall of code, look for the code …
Daily Refactor #54: Move Method to KanbanPane
The Refactoring Today I did another simple refactoring by moving a method from Kanban to KanbanPane. Before 1 2 3 4 5 6 7 8 9 10 11 12 # app/models/kanban.rb class Kanban # Sort and group a set of issues based on IssuePriority#position def group_by_priority_position(issues) return issues.group_by {|issue| issue.priority }.sort {|a,b| a[0].position b[0].position } …
Daily Refactor #53: Move Method to KanbanPane
The Refactoring Since creating the new KanbanPane class, there has been some wrapper methods to access Kanban’s private utility methods. This refactoring uses move method to move that utility method from Kanban to KanbanPane. Before 1 2 3 4 5 6 7 8 9 10 11 12 # app/models/kanban.rb class Kanban def missing_settings(pane, options={}) skip_status …