Remove duplication at the deprecated methods
This commit is contained in:
parent
61865123f4
commit
ed1862036c
|
@ -8,28 +8,20 @@ module SimpleForm
|
|||
end
|
||||
|
||||
def label_input(context=nil)
|
||||
options[:label] == false ? deprecated_input(context) : (deprecated_label(context) + deprecated_input(context))
|
||||
if options[:label] == false
|
||||
deprecated_component(:input ,context)
|
||||
else
|
||||
deprecated_component(:label, context) + deprecated_component(:input, context)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deprecated_input(context)
|
||||
method = method(:input)
|
||||
def deprecated_component(namespace ,context)
|
||||
method = method(namespace)
|
||||
|
||||
if method.arity == 0
|
||||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: 'input' })
|
||||
|
||||
method.call
|
||||
else
|
||||
method.call(context)
|
||||
end
|
||||
end
|
||||
|
||||
def deprecated_label(context)
|
||||
method = method(:label)
|
||||
|
||||
if method.arity == 0
|
||||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: 'label' })
|
||||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: namespace })
|
||||
|
||||
method.call
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue