Skip to content

Commit f11db24

Browse files
committed
Remove code duplication in ActiveResource::Request#==
1 parent c7fc06f commit f11db24

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/active_resource/http_mock.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,7 @@ def initialize(method, path, body = nil, headers = {}, options = {})
284284
end
285285

286286
def ==(req)
287-
if @options && @options[:omit_query_in_path]
288-
remove_query_params_from_path == req.remove_query_params_from_path && method == req.method && headers_match?(req)
289-
else
290-
path == req.path && method == req.method && headers_match?(req)
291-
end
287+
same_path?(req) && method == req.method && headers_match?(req)
292288
end
293289

294290
def to_s
@@ -303,6 +299,14 @@ def remove_query_params_from_path
303299
end
304300

305301
private
302+
def same_path(req)
303+
if @options && @options[:omit_query_in_path]
304+
remove_query_params_from_path == req.remove_query_params_from_path
305+
else
306+
path == req.path
307+
end
308+
end
309+
306310
def headers_match?(req)
307311
# Ignore format header on equality if it's not defined
308312
format_header = ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[method]

0 commit comments

Comments
 (0)