2011-09-02 14:33:03 -04:00
|
|
|
module SimpleForm
|
|
|
|
module Wrappers
|
2011-09-03 03:15:47 -04:00
|
|
|
# `Single` is an optimization for a wrapper that has only one component.
|
2011-09-02 14:33:03 -04:00
|
|
|
class Single < Many
|
2011-09-03 03:08:36 -04:00
|
|
|
def initialize(name, options={})
|
|
|
|
super(name, [name], options)
|
2011-09-02 16:14:23 -04:00
|
|
|
end
|
|
|
|
|
2011-09-02 14:33:03 -04:00
|
|
|
def render(input)
|
|
|
|
options = input.options
|
2012-01-19 20:26:51 -05:00
|
|
|
if options[namespace] != false
|
2011-09-02 14:33:03 -04:00
|
|
|
content = input.send(namespace)
|
|
|
|
wrap(input, options, content) if content
|
2012-01-19 20:25:43 -05:00
|
|
|
end
|
2011-09-02 14:33:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-01-19 20:25:43 -05:00
|
|
|
end
|