module ActiveModel::Naming
def self.model_name_from_record_or_class(record_or_class)
def self.model_name_from_record_or_class(record_or_class) (record_or_class.is_a?(Class) ? record_or_class : record_or_class.class).model_name end
def self.plural(record_or_class)
ActiveModel::Naming.plural(post) # => "posts"
Returns the plural class name of a record or class. Examples:
def self.plural(record_or_class) model_name_from_record_or_class(record_or_class).plural end
def self.singular(record_or_class)
ActiveModel::Naming.singular(post) # => "post"
Returns the singular class name of a record or class. Examples:
def self.singular(record_or_class) model_name_from_record_or_class(record_or_class).singular end
def self.uncountable?(record_or_class)
ActiveModel::Naming.uncountable?(Sheep) # => true
Identifies whether the class name of a record or class is uncountable. Examples:
def self.uncountable?(record_or_class) plural(record_or_class) == singular(record_or_class) end
def model_name
Returns an ActiveModel::Name object for module. It can be
def model_name @_model_name ||= ActiveModel::Name.new(self) end