TollFree should not override other things which may block the call

Stephen Paul Weber created

Change summary

lib/call_attempt.rb | 82 +++++++++++++++++++++++-----------------------
1 file changed, 41 insertions(+), 41 deletions(-)

Detailed changes

lib/call_attempt.rb 🔗

@@ -68,47 +68,6 @@ class CallAttempt
 		as_json.to_json(*args)
 	end
 
-	class TollFree
-		CallAttempt.register do |rate:, customer:, **kwargs|
-			if rate&.zero?
-				new(
-					**kwargs
-						.merge(customer_id: customer.customer_id, sgx: customer.sgx)
-						.slice(*value_semantics.attributes.map(&:name))
-				)
-			end
-		end
-
-		value_semantics do
-			customer_id String
-			from String
-			to(/\A\+\d+\Z/)
-			sgx Blather::JID
-			call_id String
-			direction Either(:inbound, :outbound)
-		end
-
-		def to_render
-			["#{direction}/connect", { locals: to_h }]
-		end
-
-		def to_s
-			"TollFree"
-		end
-
-		def create_call(fwd, *args, &block)
-			fwd.create_call(*args, &block)
-		end
-
-		def as_json(*)
-			to_h
-		end
-
-		def to_json(*args)
-			as_json.to_json(*args)
-		end
-	end
-
 	class Expired
 		CallAttempt.register do |customer:, direction:, **|
 			new(direction: direction) if customer.plan_name && !customer.active?
@@ -298,4 +257,45 @@ class CallAttempt
 				.slice(*value_semantics.attributes.map(&:name))
 		)
 	end
+
+	class TollFree
+		CallAttempt.register do |rate:, customer:, **kwargs|
+			if rate&.zero?
+				new(
+					**kwargs
+						.merge(customer_id: customer.customer_id, sgx: customer.sgx)
+						.slice(*value_semantics.attributes.map(&:name))
+				)
+			end
+		end
+
+		value_semantics do
+			customer_id String
+			from String
+			to(/\A\+\d+\Z/)
+			sgx Blather::JID
+			call_id String
+			direction Either(:inbound, :outbound)
+		end
+
+		def to_render
+			["#{direction}/connect", { locals: to_h }]
+		end
+
+		def to_s
+			"TollFree"
+		end
+
+		def create_call(fwd, *args, &block)
+			fwd.create_call(*args, &block)
+		end
+
+		def as_json(*)
+			to_h
+		end
+
+		def to_json(*args)
+			as_json.to_json(*args)
+		end
+	end
 end