Sha256: f95a9ba976ebf28eb1d24a5584d89f65284cf3abfdef95572a6f22021ba41cda

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

# encoding: utf-8
module CouchRest
  module Model
    module Errors

      class CouchRestModelError < StandardError; end

      # Raised when a persisence method ending in ! fails validation. The message
      # will contain the full error messages from the +Document+ in question.
      #
      # Example:
      #
      # <tt>Validations.new(person.errors)</tt>
      class Validations < CouchRestModelError
        attr_reader :document
        def initialize(document)
          @document = document
          super("Validation Failed: #{@document.errors.full_messages.join(", ")}")
        end
      end
    end

    class DocumentNotFound < Errors::CouchRestModelError; end

    class DatabaseNotDefined < Errors::CouchRestModelError
      def initialize(msg = nil)
        msg ||= "Database must be defined in model or view!"
        super(msg)
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
couchrest_model-2.2.0.beta2 lib/couchrest/model/errors.rb
couchrest_model-2.2.0.beta1 lib/couchrest/model/errors.rb
couchrest_model-2.1.0.rc1 lib/couchrest/model/errors.rb
couchrest_model-2.1.0.beta2 lib/couchrest/model/errors.rb
couchrest_model-2.1.0.beta1 lib/couchrest/model/errors.rb