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