Skip to content

Instantly share code, notes, and snippets.

View apanzerj's full-sized avatar

Adam Panzer apanzerj

View GitHub Profile
@fnando
fnando / polite.rb
Created January 28, 2011 18:12
ActiveRecord macro example
require "active_record"
module Polite
BAD_WORDS = ["fuck", "asshole", "motherfucker", "cunt", "cock", "dickhead"]
ESCAPED = BAD_WORDS.collect {|word| Regexp.escape(word)}
RE = /(#{ESCAPED.join("|")})/i
def self.extended(base)
base.extend ClassMethods
end