Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove explicit respond_to? and Validator#setup call #10716
This is the "bottom line" of my PR: apotonick@543c59d#L2L88
I could get my stuff working using the existing code. However, my main intend is to remove the
Are you worried about the change? Is it because the options contain a
No. I just want to know more about the motivation of this pull request.
It is awkward, but it is fine to me.
I'm not sure of this.
if validator.respond_to?(:setup) ActiveSupport::Deprecation.warn 'The `setup` instance method is deprecated and will be removed on Rails 4.2. Define `setup!` without arguments instead.' validator.setup(self) end
You can even provide a code snippet in the deprecation message to make explicit what the users have to do:
To test you can define a Validator class with the
def test_setup_is_deprecated assert_deprecated do Class.new do include ActiveModel::Validations validates_with MyDeprecatedValidator end end end
Dunno how to change a PR to another branch, here it goes: https://github.com/apotonick/rails/tree/deprecate-validator-setup rebased to current rails/rails:master and including updated exception and CHANGELOG entry.