class SimpleForm::Wrappers::Single

`Single` is an optimization for a wrapper that has only one component.

Public Class Methods

new(name, wrapper_options = {}, options = {}) click to toggle source
Calls superclass method SimpleForm::Wrappers::Many.new
# File lib/simple_form/wrappers/single.rb, line 6
def initialize(name, wrapper_options = {}, options = {})
  @component = Leaf.new(name, options)

  super(name, [@component], wrapper_options)
end

Public Instance Methods

render(input) click to toggle source
# File lib/simple_form/wrappers/single.rb, line 12
def render(input)
  options = input.options
  if options[namespace] != false
    content = @component.render(input)
    wrap(input, options, content) if content
  end
end

Private Instance Methods

html_options(options) click to toggle source
Calls superclass method SimpleForm::Wrappers::Many#html_options
# File lib/simple_form/wrappers/single.rb, line 22
def html_options(options)
  %i[label input].include?(namespace) ? {} : super
end