1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00
heartcombo--simple_form/lib/simple_form/wrappers/single.rb

19 lines
452 B
Ruby
Raw Normal View History

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)
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