Sha256: 311ef833228193bb82dfd5de3995c15016c783b71b3428af4ae20b3aa5ae39d0

Contents?: true

Size: 707 Bytes

Versions: 11

Compression:

Stored size: 707 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Traits
    module Hint
      def hint_id
        return nil unless hint_element.active?

        build_id('hint')
      end

    private

      def hint_element
        @hint_element ||= if @hint.nil?
                            Elements::Null.new
                          else
                            Elements::Hint.new(@builder, @object_name, @attribute_name, **hint_content)
                          end
      end

      def hint_content
        case @hint
        when Hash
          @hint
        when Proc
          { content: @hint }
        else
          fail(ArgumentError, %(hint must be a Proc or Hash))
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.3.0b1 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.2.0 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.9 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.8 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.7 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.7b2 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.7b1 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.6 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.5 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.4 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.3 lib/govuk_design_system_formbuilder/traits/hint.rb