lib/eml/uk/tns/response.rb in eml-2.0.0 vs lib/eml/uk/tns/response.rb in eml-2.1.0

- old
+ new

@@ -5,16 +5,30 @@ module UK module TNS class Response extend T::Sig + sig { returns(T::Array[EML::UK::Models::TNS::Transaction]) } attr_reader :transactions sig { params(response: T::Hash[Symbol, T.untyped]).void } def initialize(response) - @transactions = response[:Transactions]. + @transactions = T.let( + model_transactions(response), + T::Array[EML::UK::Models::TNS::Transaction] + ) + end + + private + + sig do + params(response: T::Hash[Symbol, T.untyped]). + returns(T::Array[EML::UK::Models::TNS::Transaction]) + end + def model_transactions(response) + response[:Transactions]. each_with_object([]) do |raw_transaction, transactions| - transactions << EML::UK::Models::TNSTransaction. + transactions << EML::UK::Models::TNS::Transaction. new(raw_transaction) end end end end