Make explicit methods that triggered the deprecation.

This commit is contained in:
José Valim 2011-12-08 09:47:18 +01:00
parent 259640e4cb
commit 3428edc12e
1 changed files with 6 additions and 5 deletions

View File

@ -161,10 +161,10 @@ module SimpleForm
## SETUP ## SETUP
DEPRECATED = %w(hint_tag hint_class error_tag error_class wrapper_tag wrapper_class wrapper_error_class components html5) DEPRECATED = %w(hint_tag hint_class error_tag error_class wrapper_tag wrapper_class wrapper_error_class components html5)
@@deprecated = false @@deprecated = []
DEPRECATED.each do |method| DEPRECATED.each do |method|
class_eval "def self.#{method}=(*); @@deprecated = true; end" class_eval "def self.#{method}=(*); @@deprecated << :#{method}=; end"
class_eval "def self.#{method}; ActiveSupport::Deprecation.warn 'SimpleForm.#{method} is deprecated and has no effect'; end" class_eval "def self.#{method}; ActiveSupport::Deprecation.warn 'SimpleForm.#{method} is deprecated and has no effect'; end"
end end
@ -183,9 +183,10 @@ module SimpleForm
def self.setup def self.setup
yield self yield self
if @@deprecated unless @@deprecated.empty?
raise "[SIMPLE FORM] Your simple form initializer file is using an outdated configuration API. " << raise "[SIMPLE FORM] Your simple form initializer file is using the following methods: #{@@deprecated.to_sentence}. " <<
"Updating to the new API is easy and fast. Check for more info here: https://github.com/plataformatec/simple_form/wiki/Upgrading-to-Simple-Form-2.0" "Those methods are part of the outdated configuration API. Updating to the new API is easy and fast. " <<
"Check for more info here: https://github.com/plataformatec/simple_form/wiki/Upgrading-to-Simple-Form-2.0"
end end
end end
end end