def self.coerce(a,b)
if a.kind_of? URITemplate
if a.class == b.class
return [a,b,false,false]
end
b_as_a = a.class.try_convert(b)
if b_as_a
return [a,b_as_a,false,true]
end
end
if b.kind_of? URITemplate
a_as_b = b.class.try_convert(a)
if a_as_b
return [a_as_b, b, true, false]
end
end
bc = self.try_convert(b)
if bc.kind_of? URITemplate
a_as_b = bc.class.try_convert(a)
if a_as_b
return [a_as_b, bc, true, true]
end
end
raise ArgumentError, "Expected at least on URITemplate, but got #{a.inspect} and #{b.inspect}" unless a.kind_of? URITemplate or b.kind_of? URITemplate
raise ArgumentError, "Cannot coerce #{a.inspect} and #{b.inspect} into a common representation."
end