From 31c281390d1ab5f43463dcc71c3f925f0bf2672c Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Wed, 5 Jun 2024 19:46:12 -0700 Subject: [PATCH] Add explanations for why `Item#pb_{species,color}` would return `nil` --- app/models/item.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index 3ec79c43..52e621a4 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -208,7 +208,11 @@ class Item < ApplicationRecord end # If this is a PB item, return the corresponding Color, inferred from the - # item name. If it's not a PB item, or we fail to infer, return nil. + # item name. If it's not a PB item, or we fail to infer a specific color, + # return nil. (This is expected to be nil for some PB items, like the "Aisha + # Collar", which belong to many colors. It can also be nil for PB items for + # new colors we haven't manually added to the database yet, or if a PB item + # is named strangely in the future.) def pb_color return nil unless pb? @@ -226,7 +230,10 @@ class Item < ApplicationRecord end # If this is a PB item, return the corresponding Species, inferred from the - # item name. If it's not a PB item, or we fail to infer, return nil. + # item name. If it's not a PB item, or we fail to infer a specific species, + # return nil. (This is not expected to be nil in general, but could be for PB + # items for new species we haven't manually added to the database yet, or if + # a PB item is named strangely in the future.) def pb_species return nil unless pb? normalized_name = name.downcase