The Refactoring Today’s refactoring is just like yesterday’s but I wanted to show a quick tip with #create! I didn’t mention. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class SourceVersion < ActiveRecord::Base include SecondDatabase set_table_name :versions def self.migrate all.each do |source_version| v = Version.new v.attributes …
Tag: ruby
Daily Refactor #69: Inline Temp in SourceNews#migrate
I wanted to start refactoring my Redmine merge plugin now. I’m getting it ready for a release so doing a few refactorings now will help me make sure it’s working properly. The Refactoring Using inline temp I was able to clean up how the SourceNews#migrate converts data from one database to the other database. Before …
Daily Refactor #68: Extract Class to New Controller
The Refactoring Today I used extract class to move the #calendar method from IssuesController to it’s own controller. This is part of a large refactoring plan I have to get IssuesController slimmed down to a more manageable size. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 …
Daily Refactor #67: Pull Up Method to ApplicationController
The Refactoring After a two hour Developer Meeting for Redmine this morning, I’m too drained to tackle the entire refactoring for #find_optional_project. I did use pull up method to remove the duplication in the GanttsController and IssuesController though. Before 1 2 3 4 5 6 7 # app/controllers/issues_controller.rb class IssuesController params[:controller], :action => params[:action]}, @project, …
Daily Refactor #66: Pull Up Method to ApplicationController
The Refactoring Today I cleaned up one of the duplications from yesterday’s refactoring, using pull up method. Before 1 2 3 4 5 6 7 8 9 # app/controllers/issues_controller.rb class IssuesController < ApplicationController def query_statement_invalid(exception) logger.error "Query::StatementInvalid: #{exception.message}" if logger session.delete(:query) sort_clear render_error "An error occurred while executing the query and has been logged. Please …