Module: RailsAiContext::CountPhrase

Overview

Renders a count with its noun. Raw interpolation reads wrong at one ("1 models"), and every tool and serializer that reports a count needs the same fix, so they share this rather than each spelling it out.

Class Method Summary collapse

Class Method Details

.call(count, noun, plural: nil) ⇒ Object

Pass plural where the inflector's answer is wrong for the domain: database docs say indexes, not the inflector's indices.



12
13
14
# File 'lib/rails_ai_context/count_phrase.rb', line 12

def self.call(count, noun, plural: nil)
  "#{count} #{count == 1 ? noun : plural || noun.pluralize}"
end