Module: DespamilatorRails::DataMapperValidator

Defined in:
lib/despamilator_rails/data_mapper_validator.rb

Instance Method Summary collapse

Instance Method Details

#default_despamilator_detection_responseObject



14
15
16
17
18
# File 'lib/despamilator_rails/data_mapper_validator.rb', line 14

def default_despamilator_detection_response
  lambda { |attribute, value, dspam|
    [false, "looks like spam"]
  }
end

#setup_despamilation_detection_for(attribute) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/despamilator_rails/data_mapper_validator.rb', line 4

def setup_despamilation_detection_for attribute

    validates_with_block attribute do
      text = send(attribute)
      dspam = Despamilator.new(text)
      despamilator_callback(attribute, text, dspam) if dspam.score >= despamilator_threshold
    end

end