2014-03-10 21:06:55 +00:00
|
|
|
module SimpleForm
|
|
|
|
module Wrappers
|
|
|
|
class Leaf
|
2014-03-11 22:41:25 +00:00
|
|
|
attr_reader :namespace
|
2014-03-10 21:06:55 +00:00
|
|
|
|
2014-03-11 22:12:08 +00:00
|
|
|
def initialize(namespace, options = {})
|
2014-03-10 21:06:55 +00:00
|
|
|
@namespace = namespace
|
2014-03-10 21:40:54 +00:00
|
|
|
@options = options
|
2014-03-10 21:06:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def render(input)
|
2014-03-11 18:54:18 +00:00
|
|
|
method = input.method(@namespace)
|
|
|
|
|
|
|
|
if method.arity == 0
|
2014-03-11 19:06:45 +00:00
|
|
|
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: @namespace })
|
2014-03-11 18:54:18 +00:00
|
|
|
|
|
|
|
method.call
|
|
|
|
else
|
2014-03-11 22:41:25 +00:00
|
|
|
method.call(@options)
|
2014-03-11 18:54:18 +00:00
|
|
|
end
|
2014-03-10 21:06:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def find(name)
|
2014-03-14 13:57:34 +00:00
|
|
|
self if @namespace == name
|
2014-03-10 21:06:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|