Skip to content

Commit

Permalink
ActiveModel::Conversion documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel committed Jan 14, 2010
1 parent 582228e commit 23e434f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion activemodel/README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ to then present a common interface to the Action Pack helpers.


You can include functionality from the following modules: You can include functionality from the following modules:


* Callbacks * Adding callbacks to your class


class MyClass class MyClass
extend ActiveModel::Callbacks extend ActiveModel::Callbacks
Expand All @@ -31,3 +31,11 @@ You can include functionality from the following modules:


{Learn more}[link:classes/ActiveModel/CallBacks.html] {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

13 changes: 12 additions & 1 deletion activemodel/lib/active_model/conversion.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,16 @@
module ActiveModel 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 module Conversion
def to_model def to_model
self self
Expand Down

0 comments on commit 23e434f

Please sign in to comment.