heartcombo--simple_form/lib/simple_form/wrappers/leaf.rb

29 lines
575 B
Ruby
Raw Normal View History

module SimpleForm
module Wrappers
class Leaf
attr_reader :namespace
2014-03-11 22:12:08 +00:00
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)
2014-03-14 13:57:34 +00:00
self if @namespace == name
end
end
end
end