lib/couch_potato/validation.rb in couch_potato-0.6.0 vs lib/couch_potato/validation.rb in couch_potato-0.7.0.pre.1

- old
+ new

@@ -1,16 +1,20 @@ +require 'active_model' +require 'active_model/translation' + module CouchPotato module Validation def self.included(base) #:nodoc: - case CouchPotato::Config.validation_framework - when :validatable - require 'couch_potato/validation/with_validatable' - base.send :include, CouchPotato::Validation::WithValidatable - when :active_model - require 'couch_potato/validation/with_active_model' - base.send :include, CouchPotato::Validation::WithActiveModel - else - raise "Unknown CouchPotato::Config.validation_framework #{CouchPotato::Config.validation_framework.inspect}, options are :validatable or :active_model" - end + base.send :include, ::ActiveModel::Validations + base.send :include, ::ActiveModel::Validations::Callbacks end end -end \ No newline at end of file +end + +# provide same interface to errors object as in Validatable +module ::ActiveModel + class Errors + def errors + self + end + end +end