aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-07-21 00:51:57 -0500
committerJoshua Peek <josh@joshpeek.com>2009-07-21 00:51:57 -0500
commit92c00d75869b173f44ff9d68f219a99e6dc3bd82 (patch)
treea5c11b3810d7739de8dcac6cedaa2879810de4a8 /activemodel/lib/active_model
parent6944b391cddbf1a3ffb3ac4ac588fa4b3d50f430 (diff)
downloadrails-92c00d75869b173f44ff9d68f219a99e6dc3bd82.tar.gz
rails-92c00d75869b173f44ff9d68f219a99e6dc3bd82.tar.bz2
rails-92c00d75869b173f44ff9d68f219a99e6dc3bd82.zip
AMo conversion helper
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/api_compliant.rb25
-rw-r--r--activemodel/lib/active_model/conversion.rb8
2 files changed, 8 insertions, 25 deletions
diff --git a/activemodel/lib/active_model/api_compliant.rb b/activemodel/lib/active_model/api_compliant.rb
deleted file mode 100644
index 26f83feb6b..0000000000
--- a/activemodel/lib/active_model/api_compliant.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module ActiveModel
- module APICompliant
- include Naming
-
- def self.extended(klass)
- klass.class_eval do
- include Validations
- include InstanceMethods
- end
- end
-
- module InstanceMethods
- def to_model
- if respond_to?(:new_record?)
- self.class.class_eval { def to_model() self end }
- to_model
- else
- raise "In order to be ActiveModel API compliant, you need to define " \
- "a new_record? method, which should return true if it has not " \
- "yet been persisted."
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb
new file mode 100644
index 0000000000..d5c65920f6
--- /dev/null
+++ b/activemodel/lib/active_model/conversion.rb
@@ -0,0 +1,8 @@
+module ActiveModel
+ # Include ActiveModel::Conversion if your object "acts like an ActiveModel model".
+ module Conversion
+ def to_model
+ self
+ end
+ end
+end