Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for custom filtering functions. #1

Merged
merged 9 commits into from
Nov 23, 2011
Merged

Added support for custom filtering functions. #1

merged 9 commits into from
Nov 23, 2011

Conversation

dadittoz
Copy link

I didn't add any tests for configuration. Existing tests pass correctly. Pull it if you like.

@holli
Copy link
Owner

holli commented Nov 19, 2011

I'll leave it here for the time being.

This would need better tests and some info in the Readme.md before pulling.

For someone who is thinking of using the plugin. This patch allows to add custom filtering functions in initializers. Quite handy for sanitizing html, some specific numbers, etc. I guess example would be something like:

AutoStripAttributes::Config.set_filter :remove_html do |value|
  Sanitize.clean(value, HTML::RELAXED)
end

@holli
Copy link
Owner

holli commented Nov 19, 2011

@dadittoz if you have better examples etc. You could include those in the Readme.md after current examples and make some tests for those custom validators.

Otherwise I'll pull when I need that feature for myself for the first time :)

@dadittoz
Copy link
Author

Looks like that's it. Let me know if you anything else should be added.

holli added a commit that referenced this pull request Nov 23, 2011
Added support for custom filtering functions.
@holli holli merged commit 59a359e into holli:master Nov 23, 2011
holli added a commit that referenced this pull request Nov 23, 2011
Added some tests
Some minor fixes in the class
Related to #1
holli added a commit that referenced this pull request Nov 23, 2011
readme updated
related to #1
@holli
Copy link
Owner

holli commented Nov 23, 2011

Cool, thanks for the patch.

I did some minor things:

:nullify is now with
(value.respond_to?(:'blank?') and value.respond_to?(:'empty?') and value.blank?) ? nil : value

so that tests go right with both ruby 1.9 and 1.8.7. Also bit more tests included.

I bumpt version to 2.0 and added info to readme about versions (and reference to this pull request/issue). New version is in rubygems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants