diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-17 15:52:33 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-17 15:52:33 +1100 |
commit | fbc7c2beca0433d4b070e3292a1009a94987d5c0 (patch) | |
tree | 9bd77f856596ae0d358b34b96253fa44ee05350e /activemodel/lib | |
parent | 87bd8c803b530fedde3d440f991da2726541990c (diff) | |
download | rails-fbc7c2beca0433d4b070e3292a1009a94987d5c0.tar.gz rails-fbc7c2beca0433d4b070e3292a1009a94987d5c0.tar.bz2 rails-fbc7c2beca0433d4b070e3292a1009a94987d5c0.zip |
Adding ActiveModel::Naming documentation
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 4cd68a0c89..b9fb5fe0c8 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -1,6 +1,7 @@ require 'active_support/inflector' module ActiveModel + class Name < String attr_reader :singular, :plural, :element, :collection, :partial_path alias_method :cache_key, :collection @@ -35,6 +36,21 @@ module ActiveModel end end + # ActiveModel::Naming is a module that creates a +model_name+ method on your + # object. + # + # To implement, just extend ActiveModel::Naming in your object: + # + # class BookCover + # exten ActiveModel::Naming + # end + # + # BookCover.model_name #=> "BookCover" + # BookCover.model_name.human #=> "Book cover" + # + # Providing the functionality that ActiveModel::Naming provides in your object + # is required to pass the ActiveModel Lint test. So either extending the provided + # method below, or rolling your own is required.. module Naming # Returns an ActiveModel::Name object for module. It can be # used to retrieve all kinds of naming-related information. @@ -42,4 +58,5 @@ module ActiveModel @_model_name ||= ActiveModel::Name.new(self) end end + end |