lib/loqate/mappers/error_mapper.rb in loqate-0.2.0 vs lib/loqate/mappers/error_mapper.rb in loqate-0.3.0

- old
+ new

@@ -12,15 +12,21 @@ # Creates errors from an API response # # @return [Array<Error>] An array of errors # def map(items) - items.map do |item| - attributes = item.transform_keys { |attribute| Util.underscore(attribute) } - attributes[:id] = attributes.delete(:error).to_i + items.map { |item| map_one(item) } + end - Loqate::Error.new(attributes) - end + # Creates an error from an API response + # + # @return [Error] A concrete instance of Error + # + def map_one(item) + attributes = item.transform_keys { |attribute| Util.underscore(attribute) } + attributes[:id] = attributes.delete(:error).to_i + + Loqate::Error.new(attributes) end end end end