Module: Gorillib::Model::Naming

Defined in:
lib/gorillib/model/active_model_naming.rb

Overview

Active Model Naming

Creates a model_name method on your object.

To implement, just extend ActiveModel::Naming in your object:

class BookCover
extend ActiveModel::Naming
end

BookCover.model_name        # => "BookCover"
BookCover.model_name.human  # => "Book cover"

BookCover.model_name.i18n_key              # => :book_cover
BookModule::BookCover.model_name.i18n_key  # => :"book_module/book_cover"

Providing the functionality that ActiveModel::Naming provides in your object is required to pass the Active Model Lint test. So either extending the provided method below, or rolling your own is required.

Instance Method Summary collapse

Instance Method Details

#model_nameObject

Returns a Name object for module, which can be used to retrieve all kinds of naming-related information.



83
84
85
# File 'lib/gorillib/model/active_model_naming.rb', line 83

def model_name
  @_model_name ||= Gorillib::Model::Name.new(self, namespace)
end