Created
January 20, 2014 18:33
-
-
Save cleytonmessias/8526128 to your computer and use it in GitHub Desktop.
sanitizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sanitizer | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def sanitize(*args, target) | |
args.each do |column| | |
delegate column, "#{column}=", to: target | |
class_eval <<-RUBY | |
def #{column}=(value) | |
#{target}.send("#{column}=", Sanitize.clean(value)) | |
end | |
RUBY | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment