Move credit_to lookup into relevant class

Stephen Paul Weber created

Change summary

lib/registration.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -39,8 +39,7 @@ class Registration
 			if customer.active?
 				Finish.new(customer, tel)
 			elsif CONFIG[:approved_domains].key?(jid.domain.to_sym)
-				credit_to = CONFIG[:approved_domains][jid.domain.to_sym]
-				Allow.new(customer, tel, credit_to)
+				Allow.for(customer, tel, jid)
 			else
 				new(customer, tel)
 			end
@@ -86,6 +85,11 @@ class Registration
 		end
 
 		class Allow < Activation
+			def self.for(customer, tel, jid)
+				credit_to = CONFIG[:approved_domains][jid.domain.to_sym]
+				new(customer, tel, credit_to)
+			end
+
 			def initialize(customer, tel, credit_to)
 				super(customer, tel)
 				@credit_to = credit_to