aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2012-03-02 23:20:17 -0500
committerGuillermo Iguaran <guilleiguaran@gmail.com>2012-03-02 23:59:55 -0500
commit3b822e91d1a6c4eab0064989bbd07aae3a6d0d08 (patch)
treeaf57a545ec7ea8a735f1eea6b70804c275b48c23 /activemodel/lib
parent14f06dd8711231157435282cb288728c5f643303 (diff)
downloadrails-3b822e91d1a6c4eab0064989bbd07aae3a6d0d08.tar.gz
rails-3b822e91d1a6c4eab0064989bbd07aae3a6d0d08.tar.bz2
rails-3b822e91d1a6c4eab0064989bbd07aae3a6d0d08.zip
Add ActiveModel::Model, a mixin to make Ruby objects to work with AP inmediatly
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model.rb1
-rw-r--r--activemodel/lib/active_model/model.rb22
2 files changed, 23 insertions, 0 deletions
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb
index 85514e63fd..2586147a20 100644
--- a/activemodel/lib/active_model.rb
+++ b/activemodel/lib/active_model.rb
@@ -39,6 +39,7 @@ module ActiveModel
autoload :Errors
autoload :Lint
autoload :MassAssignmentSecurity
+ autoload :Model
autoload :Name, 'active_model/naming'
autoload :Naming
autoload :Observer, 'active_model/observing'
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