Sha256: aa6d3b3891155b9de3abddf68d7b40c558c2ee4f142542d75977d72d3312afa0

Contents?: true

Size: 592 Bytes

Versions: 8

Compression:

Stored size: 592 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 ||= Elements::Hint.new(@builder, @object_name, @attribute_name, **hint_content)
      end

      def hint_content
        case @hint
        when NilClass
          {}
        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

8 entries across 8 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-2.1.2 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.1 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.1.0 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.0.0 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.0.0b4 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.0.0b3 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.0.0b2 lib/govuk_design_system_formbuilder/traits/hint.rb
govuk_design_system_formbuilder-2.0.0b1 lib/govuk_design_system_formbuilder/traits/hint.rb