diff --git a/app/models/color.rb b/app/models/color.rb index e0c1aa70..8872fc44 100644 --- a/app/models/color.rb +++ b/app/models/color.rb @@ -35,6 +35,16 @@ class Color < ApplicationRecord end end + def default_gender_presentation + if name.downcase.ends_with? "boy" + :masc + elsif name.downcase.ends_with? "girl" + :fem + else + nil + end + end + def self.pranks_funny? now = Time.now.in_time_zone('Pacific Time (US & Canada)') now.month == 4 && now.day == 1 diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index beba90d9..96c31818 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -107,9 +107,11 @@ class PetType < ApplicationRecord def canonical_pet_state # For consistency (randomness is always scary!), we use the PetType ID to - # determine which gender to prefer. That way, it'll be stable, but we'll - # still get the *vibes* of uniform randomness. - preferred_gender = id % 2 == 0 ? :fem : :masc + # determine which gender to prefer, if it's not built into the color. That + # way, it'll be stable, but we'll still get the *vibes* of randomness. + preferred_gender = color.default_gender_presentation || + (id % 2 == 0 ? :fem : :masc) + puts preferred_gender # NOTE: If this were only being called on one pet type at a time, it would # be more efficient to send this as a single query with an `order` part and