Sha256: c896734941609f29f19ddcf90b93edbd550b34e7c6848ffa2f96894fa84333bd

Contents?: true

Size: 1.69 KB

Versions: 18

Compression:

Stored size: 1.69 KB

Contents

# frozen-string-literal: true

module Sequel
  # Exception class raised when +raise_on_save_failure+ is set and a before hook returns false
  # or an around hook doesn't call super or yield.
  class HookFailed < Error
    # The Sequel::Model instance related to this error.
    attr_reader :model

    def initialize(message=nil, model=nil)
      @model = model
      super(message)
    end
  end

  # Alias for HookFailed, kept for backwards compatibility
  BeforeHookFailed = HookFailed
  
  # Exception class raised when +require_modification+ is set and an UPDATE or DELETE statement to modify the dataset doesn't
  # modify a single row.
  NoExistingObject = Class.new(Error)
  
  # Raised when an undefined association is used when eager loading.
  UndefinedAssociation = Class.new(Error)

  # Raised when a mass assignment method is called in strict mode with either a restricted column
  # or a column without a setter method.
  MassAssignmentRestriction = Class.new(Error)
  
  # Exception class raised when +raise_on_save_failure+ is set and validation fails
  class ValidationFailed < Error
    # The Sequel::Model object related to this exception.
    attr_reader :model

    # The Sequel::Model::Errors object related to this exception.
    attr_reader :errors

    def initialize(errors=nil)
      if errors.is_a?(Sequel::Model)
        @model = errors
        errors = @model.errors
      end

      if errors.respond_to?(:full_messages)
        @errors = errors
        super(errors.full_messages.join(', '))
      else
        super
      end
    end
  end

  # Call name on each class to set the name for the class, so it gets cached.
  constants.map{|c| const_get(c)}.each do |c|
    Class === c && c.name
  end
end

Version data entries

18 entries across 17 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/sequel-4.44.0/lib/sequel/model/exceptions.rb
tdiary-5.0.5 vendor/bundle/gems/sequel-4.44.0/lib/sequel/model/exceptions.rb
tdiary-5.0.4 vendor/bundle/gems/sequel-4.44.0/lib/sequel/model/exceptions.rb
sequel-4.44.0 lib/sequel/model/exceptions.rb
sequel-4.43.0 lib/sequel/model/exceptions.rb
sequel-4.42.1 lib/sequel/model/exceptions.rb
sequel-4.42.0 lib/sequel/model/exceptions.rb
sequel-4.41.0 lib/sequel/model/exceptions.rb
sequel-4.40.0 lib/sequel/model/exceptions.rb
sequel-4.39.0 lib/sequel/model/exceptions.rb
tdiary-5.0.2 vendor/bundle/gems/sequel-4.37.0/lib/sequel/model/exceptions.rb
sequel-4.38.0 lib/sequel/model/exceptions.rb
sequel-4.37.0 lib/sequel/model/exceptions.rb
sequel-4.36.0 lib/sequel/model/exceptions.rb
tdiary-5.0.1 vendor/bundle/gems/sequel-4.35.0/lib/sequel/model/exceptions.rb
sequel-4.35.0 lib/sequel/model/exceptions.rb
sequel-4.34.0 lib/sequel/model/exceptions.rb
sequel-4.33.0 lib/sequel/model/exceptions.rb