lib/sportradar/api/football/play_statistics.rb in sportradar-api-0.11.22 vs lib/sportradar/api/football/play_statistics.rb in sportradar-api-0.11.23

- old
+ new

@@ -5,15 +5,16 @@ attr_accessor :response, :kick, :return, :rush, :defense, :receive, :punt, :penalty, :pass, :first_down, :field_goal, :extra_point, :defense, :down_conversion def initialize(data) data = [data] if data.is_a?(Hash) @response = data data.each do |hash| - begin + var = instance_variable_get("@#{hash['stat_type']}") + unless var + instance_variable_set("@#{hash['stat_type']}", []) + var = instance_variable_get("@#{hash['stat_type']}") + end klass = self.class.stat_type_classes[hash['stat_type']] || MiscStatistics - instance_variable_set("@#{hash['stat_type']}", klass.new(hash)) - rescue => e - binding.pry - end + var << klass.new(hash) end end def self.stat_type_classes stat_type_classes ||= { \ No newline at end of file