Sha256: 9f7d79a4a2519ab3ae79466839e372cd2782963e98b8f2f026b78f9e0c9b2f4a

Contents?: true

Size: 602 Bytes

Versions: 11

Compression:

Stored size: 602 Bytes

Contents

require 'active_model'
require 'active_model/translation'

module CouchPotato
  module Validation
    module ValidationContext
      def valid?(context = nil)
        context ||= new? ? :create : :update
        super context
      end
    end

    def self.included(base) #:nodoc:
      base.send :include, ::ActiveModel::Validations
      base.send :include, ::ActiveModel::Validations::Callbacks
      base.send :include, ValidationContext
    end
  end
end

# provide same interface to errors object as in Validatable
module ::ActiveModel
  class Errors
    def errors
      self
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
couch_potato-1.17.0 lib/couch_potato/validation.rb
couch_potato-1.16.0 lib/couch_potato/validation.rb
couch_potato-1.15.0 lib/couch_potato/validation.rb
couch_potato-1.14.0 lib/couch_potato/validation.rb
couch_potato-1.13.0 lib/couch_potato/validation.rb
couch_potato-1.12.1 lib/couch_potato/validation.rb
couch_potato-1.12.0 lib/couch_potato/validation.rb
couch_potato-1.11.0 lib/couch_potato/validation.rb
couch_potato-1.10.1 lib/couch_potato/validation.rb
couch_potato-1.10.0 lib/couch_potato/validation.rb
couch_potato-1.9.0 lib/couch_potato/validation.rb