提交 23e434f0 编写于 作者: M Mikel Lindsaar

ActiveModel::Conversion documentation

上级 582228e4
......@@ -13,7 +13,7 @@ to then present a common interface to the Action Pack helpers.
You can include functionality from the following modules:
* Callbacks
* Adding callbacks to your class
class MyClass
extend ActiveModel::Callbacks
......@@ -31,3 +31,11 @@ You can include functionality from the following modules:
{Learn more}[link:classes/ActiveModel/CallBacks.html]
* For classes that already look like an Active Record object
class MyClass
include ActiveModel::Conversion
end
...returns the class itself when sent :to_model
module ActiveModel
# Include ActiveModel::Conversion if your object "acts like an ActiveModel model".
# If your object is already designed to implement all of the Active Model featurs
# include this module in your Class.
#
# class MyClass
# include ActiveModel::Conversion
# end
#
# Returns self to the <tt>:to_model</tt> method.
#
# If your model does not act like an Active Model object, then you should define
# <tt>:to_model</tt> yourself returning a proxy object that wraps your object
# with Active Model compliant methods.
module Conversion
def to_model
self
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册