Class: ForeignKeyValidation::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/foreign_key_validation/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collector) ⇒ Filter

Returns a new instance of Filter.



6
7
8
# File 'lib/foreign_key_validation/filter.rb', line 6

def initialize(collector)
  self.collector = collector
end

Instance Attribute Details

#collectorObject

Returns the value of attribute collector.



4
5
6
# File 'lib/foreign_key_validation/filter.rb', line 4

def collector
  @collector
end

Instance Method Details

#before_filter(&block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/foreign_key_validation/filter.rb', line 10

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