Sha256: 32eade30992c2aa4ae004c5f76857fc6f0662ed712701e019797dcbf67296350

Contents?: true

Size: 598 Bytes

Versions: 2

Compression:

Stored size: 598 Bytes

Contents

module ForeignKeyValidation
  module ModelExtension
    extend ActiveSupport::Concern

    module ClassMethods

      def validate_foreign_keys(opt={})
        subclasses.map {|klass| klass.send(:validate_foreign_keys, opt)} if ForeignKeyValidation.configuration.inject_subclasses

        collector = Collector.new(opt.merge(klass: self))
        collector.check!

        Filter.new(collector).before_filter do
          Validator.new(validate_against_key: collector.validate_against_key, reflection_names: collector.validate_with, object: self).validate
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreign_key_validation-1.1.1 lib/foreign_key_validation/model_extension.rb
foreign_key_validation-1.1.0 lib/foreign_key_validation/model_extension.rb