Skip to content

Commit

Permalink
Fix rubocop issues because a line moved
Browse files Browse the repository at this point in the history
  • Loading branch information
paul committed Aug 17, 2018
1 parent 0e09e4f commit d139773
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/http/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class << self
attr_accessor :default_socket_class, :default_ssl_socket_class, :default_timeout_class
attr_reader :available_features

def new(options = {})
def new(options = {}) # rubocop:disable Style/OptionHash
return options if options.is_a?(self)
super
end
Expand Down Expand Up @@ -72,12 +72,12 @@ def initialize(options = {}) # rubocop:disable Style/OptionHash
opts_w_defaults.each { |(k, v)| self[k] = v }
end

def_option :headers do |headers|
self.headers.merge(headers)
def_option :headers do |new_headers|
headers.merge(new_headers)
end

def_option :cookies do |cookies|
cookies.each_with_object self.cookies.dup do |(k, v), jar|
def_option :cookies do |new_cookies|
new_cookies.each_with_object cookies.dup do |(k, v), jar|
cookie = k.is_a?(Cookie) ? k : Cookie.new(k.to_s, v.to_s)
jar[cookie.name] = cookie.cookie_value
end
Expand All @@ -87,23 +87,23 @@ def initialize(options = {}) # rubocop:disable Style/OptionHash
self.encoding = Encoding.find(encoding)
end

def_option :features, :reader_only => true do |features|
def_option :features, :reader_only => true do |new_features|
# Normalize features from:
#
# [{feature_one: {opt: 'val'}}, :feature_two]
#
# into:
#
# {feature_one: {opt: 'val'}, feature_two: {}}
features = features.each_with_object({}) do |feature, h|
normalized_features = new_features.each_with_object({}) do |feature, h|
if feature.is_a?(Hash)
h.merge!(feature)
else
h[feature] = {}
end
end

self.features.merge(features)
features.merge(normalized_features)
end

def features=(features)
Expand Down Expand Up @@ -195,4 +195,3 @@ def argument_error!(message)
end
end
end

0 comments on commit d139773

Please sign in to comment.