Sha256: 3402c3af3d5308859f7ce9f63d4df528c5a25d17aef82c455bfc7f375ce98419

Contents?: true

Size: 684 Bytes

Versions: 11

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true
module SimpleForm
  module Wrappers
    # `Single` is an optimization for a wrapper that has only one component.
    class Single < Many
      def initialize(name, wrapper_options = {}, options = {})
        @component = Leaf.new(name, options)

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

      def render(input)
        options = input.options
        if options[namespace] != false
          content = @component.render(input)
          wrap(input, options, content) if content
        end
      end

      private

      def html_options(options)
        %i[label input].include?(namespace) ? {} : super
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
simple_form-5.3.0 lib/simple_form/wrappers/single.rb
simple_form-5.2.0 lib/simple_form/wrappers/single.rb
simple_form-5.1.0 lib/simple_form/wrappers/single.rb
simple_form-5.0.3 lib/simple_form/wrappers/single.rb
simple_form-5.0.2 lib/simple_form/wrappers/single.rb
simple_form-5.0.1 lib/simple_form/wrappers/single.rb
simple_form-5.0.0 lib/simple_form/wrappers/single.rb
simple_form-4.1.0 lib/simple_form/wrappers/single.rb
simple_form-4.0.1 lib/simple_form/wrappers/single.rb
simple_form-4.0.0 lib/simple_form/wrappers/single.rb
simple_form-3.5.1 lib/simple_form/wrappers/single.rb