Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored watchable_args and build_original_fullpath methods in Rails::Application #4470

Merged
merged 1 commit into from Jan 15, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 2 additions & 13 deletions railties/lib/rails/application.rb
Expand Up @@ -114,11 +114,8 @@ def routes_reloader #:nodoc:
# Returns an array of file paths appended with a hash of directories-extensions
# suitable for ActiveSupport::FileUpdateChecker API.
def watchable_args
files = []
files.concat config.watchable_files
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup

dirs = {}
dirs.merge! config.watchable_dirs
ActiveSupport::Dependencies.autoload_paths.each do |path|
dirs[path.to_s] = [:rb]
end
Expand Down Expand Up @@ -293,15 +290,7 @@ def initialize_console #:nodoc:
end

def build_original_fullpath(env)
path_info = env["PATH_INFO"]
query_string = env["QUERY_STRING"]
script_name = env["SCRIPT_NAME"]

if query_string.present?
"#{script_name}#{path_info}?#{query_string}"
else
"#{script_name}#{path_info}"
end
["#{env["SCRIPT_NAME"]}#{env["PATH_INFO"]}", env["QUERY_STRING"]].reject(&:blank?).join("?")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder to read than previous code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, would you prefer this instead?

def build_original_fullpath(env)
  script_and_path, query_string = "#{env['SCRIPT_NAME']}#{env['PATH_INFO']}", env['QUERY_STRING']
  query_string.present? ? "#{script_and_path}?#{query_string}" : script_and_path
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I prefer the original code, it's easier to read and has no excessively large lines of code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, no worries, reverted in pull request #4731

end
end
end