Sha256: 63c3ccf3429efc5c849980eb3b742d0711da6f3705211d6248b59dce9e0f040f

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

require "foreign_key_validation/version"
require "foreign_key_validation/errors"
require "foreign_key_validation/collector"
require "foreign_key_validation/filter"
require "foreign_key_validation/validator"
require "foreign_key_validation/model_extension"
require "ostruct"

module ForeignKeyValidation

  DEFAULT_CONFIG = {
    inject_subclasses: true,
    validate_against: :user,
    error_message: proc { |key, reflection_name, object|
      "#{key} of #{reflection_name} does not match #{object.class.name.tableize} #{key}."
    }
  }

  class << self
    attr_writer :configuration

    def configure(&blk)
      yield configuration
    end

    def configuration
      @configuration ||= OpenStruct.new(DEFAULT_CONFIG)
    end
  end
end

ActiveRecord::Base.send :include, ForeignKeyValidation::ModelExtension

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreign_key_validation-1.1.1 lib/foreign_key_validation.rb