diff options
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/api_compliant.rb | 25 | ||||
-rw-r--r-- | activemodel/lib/active_model/conversion.rb | 8 |
3 files changed, 9 insertions, 26 deletions
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb index 0665cfbae5..2de19597b1 100644 --- a/activemodel/lib/active_model.rb +++ b/activemodel/lib/active_model.rb @@ -26,7 +26,7 @@ $:.unshift(activesupport_path) if File.directory?(activesupport_path) require 'active_support' module ActiveModel - autoload :APICompliant, 'active_model/api_compliant' + autoload :Conversion, 'active_model/conversion' autoload :DeprecatedErrorMethods, 'active_model/deprecated_error_methods' autoload :Errors, 'active_model/errors' autoload :Name, 'active_model/naming' 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 |