Sha256: 43ef251038eee6a812cb17b0cc5c9ae5df575f2932cc08e9029589b3630cc6cc

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

module ForeignKeyValidation

  class Filter
    attr_accessor :collector

    def initialize(collector)
      self.collector = collector
    end

    def before_filter(&block)
      collector.klass.send :define_method, filter_name do
        self.instance_eval &block
        return true
      end
      collector.klass.send :private, filter_name.to_sym
      collector.klass.public_send :before_validation, filter_name
    end

    private

    def filter_name
      "validate_foreign_keys_on_#{collector.validate_against}"
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreign_key_validation-1.1.2 lib/foreign_key_validation/filter.rb