diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-03-02 22:38:30 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-03-02 22:38:30 -0800 |
commit | eafa58b566c770d5d5dc5706464ab4b67e453464 (patch) | |
tree | af57a545ec7ea8a735f1eea6b70804c275b48c23 /activemodel/lib/active_model | |
parent | 14f06dd8711231157435282cb288728c5f643303 (diff) | |
parent | 3b822e91d1a6c4eab0064989bbd07aae3a6d0d08 (diff) | |
download | rails-eafa58b566c770d5d5dc5706464ab4b67e453464.tar.gz rails-eafa58b566c770d5d5dc5706464ab4b67e453464.tar.bz2 rails-eafa58b566c770d5d5dc5706464ab4b67e453464.zip |
Merge pull request #5253 from guilleiguaran/amo-model
Add ActiveModel::Model, a mixin to make plain Ruby objects work with AP out of box
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/model.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/model.rb b/activemodel/lib/active_model/model.rb new file mode 100644 index 0000000000..9228d54015 --- /dev/null +++ b/activemodel/lib/active_model/model.rb @@ -0,0 +1,22 @@ +module ActiveModel + module Model + def self.included(base) + base.class_eval do + extend ActiveModel::Naming + extend ActiveModel::Translation + include ActiveModel::Validations + include ActiveModel::Conversion + end + end + + def initialize(params={}) + params.each do |attr, value| + self.send(:"#{attr}=", value) + end if params + end + + def persisted? + false + end + end +end |