SpeciesFileGroup/taxonworks

View on GitHub
app/views/taxon_names/api/v1/parse.json.jbuilder

Summary

Maintainability
Test Coverage
json.data do
  json.protonyms do
    Vendor::Biodiversity::RANKS.each do |r|
      json.set! r do
        json.array! @result[:protonyms][r] do |t|
          json.partial! '/api/v1//taxon_names/attributes', taxon_name: t
        end
      end
    end
  end

  json.set! :parse, @result[:parse]
  json.unambiguous @result[:unambiguous]
  json.existing_combination_id @result[:existing_combination_id]
end

json.other_matches do
  @result[:other_matches].keys.each do |k|
    json.set! k do
      json.array! @result[:other_matches][k] do |t|
        json.partial! '/api/v1/taxon_names/attributes', taxon_name: t
      end
    end
  end
end

if @combination
  json.combination do
    json.partial! '/api/v1/combinations/attributes', combination: @combination
  end
end