Skip to content

Instantly share code, notes, and snippets.

@cleytonmessias
Created January 20, 2014 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cleytonmessias/8526128 to your computer and use it in GitHub Desktop.
Save cleytonmessias/8526128 to your computer and use it in GitHub Desktop.
sanitizer
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