module Splam::ClassMethods
Public Instance Methods
splam_suite()
click to toggle source
# File lib/splam.rb, line 59 def splam_suite; @splam_suite; end
splammable(fieldname, threshold=100, conditions=nil, &block)
click to toggle source
Set body attribute as splammable with default threshold of 100
splammable :body
Set body attribute as splammable with custom threshold
splammable :body, 50
Set body splammable with threshold and a conditions block?
splamamble :body, 50, lambda { |record| record.skip_splam_check }
Set any Splam::Suite
options
splammable :body do |splam| splam.threshold = 150 splam.conditions = lambda { |r| r.body.size.zero? } # Set rules with #splam_key value splam.rules = [:chinese, :html] # Set rules with Class instances splam.rules = [Splam::Rules::Chinese] # Mix and match, we're all friends here splam.rules = [Splam::Rules::Chinese, :html] # Specify optional weights splam.rules = {Splam::Rules::Chinese => 1.2, :html => 5.0}
# File lib/splam.rb, line 82 def splammable(fieldname, threshold=100, conditions=nil, &block) # todo: run only certain rules # e.g. splammable :body, 100, [ :chinese, :html ] # todo: define some weighting on the model level # e.g. splammable :body, 50, { :russian => 2.0 } @splam_suite = Suite.new(fieldname, Splam::Rule.default_rules, threshold, conditions, &block) end