mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
28 lines
575 B
Ruby
28 lines
575 B
Ruby
module SimpleForm
|
|
module Wrappers
|
|
class Leaf
|
|
attr_reader :namespace
|
|
|
|
def initialize(namespace, options = {})
|
|
@namespace = namespace
|
|
@options = options
|
|
end
|
|
|
|
def render(input)
|
|
method = input.method(@namespace)
|
|
|
|
if method.arity == 0
|
|
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: @namespace })
|
|
|
|
method.call
|
|
else
|
|
method.call(@options)
|
|
end
|
|
end
|
|
|
|
def find(name)
|
|
self if @namespace == name
|
|
end
|
|
end
|
|
end
|
|
end
|