File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def aggregate_weight_for_type(type, filter: [])
82
82
}
83
83
84
84
# then sum up all of the weights across our providers
85
- providers . map ( &:weight ) . inject ( 0 , :+ )
85
+ providers . count == 1 ? 1 : providers . map ( &:weight ) . inject ( 0 , :+ )
86
86
end
87
87
88
88
def weighted_provider_for_type ( type , filter : [ ] )
@@ -99,7 +99,9 @@ def weighted_provider_for_type(type, filter: [])
99
99
filter . empty? || filter . include? ( provider_instance . class )
100
100
}
101
101
102
- # if we end up with an empty list we're in troubl
102
+ return providers . first if providers . count == 1
103
+
104
+ # if we end up with an empty list we're in trouble
103
105
raise ProviderNotFoundError , "Empty provider list found for type:#{ type } filter:#{ filter } " unless providers . any?
104
106
105
107
# get the aggregate weight, and make sure it's more than 0 after the filter
You can’t perform that action at this time.
0 commit comments