mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
moving leftover option proc into private function
This commit is contained in:
parent
e32d226151
commit
113e9fd4ef
@ -251,14 +251,6 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
OTHER_LOOKUP = ->(obj, k, ivar_map) {
|
|
||||||
case obj
|
|
||||||
when Hash
|
|
||||||
obj[ivar_map[k]]
|
|
||||||
else
|
|
||||||
obj.instance_variable_get(k)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
def merge(other)
|
def merge(other)
|
||||||
ivar_map = nil
|
ivar_map = nil
|
||||||
other_ivars = case other
|
other_ivars = case other
|
||||||
@ -271,12 +263,12 @@ module HTTPX
|
|||||||
|
|
||||||
return self if other_ivars.empty?
|
return self if other_ivars.empty?
|
||||||
|
|
||||||
return self if other_ivars.all? { |ivar| instance_variable_get(ivar) == OTHER_LOOKUP[other, ivar, ivar_map] }
|
return self if other_ivars.all? { |ivar| instance_variable_get(ivar) == access_option(other, ivar, ivar_map) }
|
||||||
|
|
||||||
opts = dup
|
opts = dup
|
||||||
|
|
||||||
other_ivars.each do |ivar|
|
other_ivars.each do |ivar|
|
||||||
v = OTHER_LOOKUP[other, ivar, ivar_map]
|
v = access_option(other, ivar, ivar_map)
|
||||||
|
|
||||||
unless v
|
unless v
|
||||||
opts.instance_variable_set(ivar, v)
|
opts.instance_variable_set(ivar, v)
|
||||||
@ -355,5 +347,14 @@ module HTTPX
|
|||||||
instance_variable_set(:"@#{k}", value)
|
instance_variable_set(:"@#{k}", value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def access_option(obj, k, ivar_map)
|
||||||
|
case obj
|
||||||
|
when Hash
|
||||||
|
obj[ivar_map[k]]
|
||||||
|
else
|
||||||
|
obj.instance_variable_get(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -135,6 +135,8 @@ module HTTPX
|
|||||||
def initialize: (?options options) -> void
|
def initialize: (?options options) -> void
|
||||||
|
|
||||||
def do_initialize: (?options options) -> void
|
def do_initialize: (?options options) -> void
|
||||||
|
|
||||||
|
def access_option: (Hash | Object obj, Symbol k, Hash[Symbol, Symbol] ivar_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
type options = Options | Hash[Symbol, untyped]
|
type options = Options | Hash[Symbol, untyped]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user