Extract the deprecation message to avoid duplication
This commit is contained in:
parent
9e3aae1da3
commit
61865123f4
|
@ -24,6 +24,16 @@ module SimpleForm
|
|||
SimpleForm::Components.eager_load!
|
||||
end
|
||||
|
||||
CUSTOM_INPUT_DEPRECATION_WARN = <<-WARN
|
||||
%{name} method now accepts a `context` argument. The method definition without the argument is deprecated and will be removed in the next Simple Form version. Change your code from:
|
||||
|
||||
def %{name}
|
||||
|
||||
to
|
||||
|
||||
def %{name}(context)
|
||||
WARN
|
||||
|
||||
## CONFIGURATION OPTIONS
|
||||
|
||||
# Method used to tidy up errors.
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
module SimpleForm
|
||||
module Components
|
||||
module LabelInput
|
||||
DEPRECATION_WARN = <<-WARN
|
||||
%{name} method now accepts a `context` argument. The method definition without the argument is deprecated and will be removed in the next Simple Form version. Change your code from:
|
||||
|
||||
def %{name}
|
||||
|
||||
to
|
||||
|
||||
def %{name}(context)
|
||||
WARN
|
||||
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
|
@ -27,7 +17,7 @@ to
|
|||
method = method(:input)
|
||||
|
||||
if method.arity == 0
|
||||
ActiveSupport::Deprecation.warn(DEPRECATION_WARN % { name: 'input' })
|
||||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: 'input' })
|
||||
|
||||
method.call
|
||||
else
|
||||
|
@ -39,7 +29,7 @@ to
|
|||
method = method(:label)
|
||||
|
||||
if method.arity == 0
|
||||
ActiveSupport::Deprecation.warn(DEPRECATION_WARN % { name: 'label' })
|
||||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: 'label' })
|
||||
|
||||
method.call
|
||||
else
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
module SimpleForm
|
||||
module Wrappers
|
||||
class Leaf
|
||||
DEPRECATION_WARN = <<-WARN
|
||||
%{name} method now accepts a `context` argument. The method definition without the argument is deprecated and will be removed in the next Simple Form version. Change your code from:
|
||||
|
||||
def %{name}
|
||||
|
||||
to
|
||||
|
||||
def %{name}(context)
|
||||
WARN
|
||||
|
||||
attr_reader :namespace, :options
|
||||
|
||||
def initialize(namespace, options={})
|
||||
|
@ -22,7 +12,7 @@ to
|
|||
method = input.method(@namespace)
|
||||
|
||||
if method.arity == 0
|
||||
ActiveSupport::Deprecation.warn(DEPRECATION_WARN % { name: @namespace })
|
||||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: @namespace })
|
||||
|
||||
method.call
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue