Class: CCS::Components::CCS::PasswordStrength

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/ccs/password_strength.rb,
lib/ccs/components/ccs/password_strength/test.rb

Overview

CCS Password Strength

This is used for generating the contact us component from the CCS - Components - Password strength

Defined Under Namespace

Classes: Test

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for password strength

{ class: 'ccs-password-strength', data: { module: 'ccs-password-strength' } }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(password_id:, password_strength_tests:) ⇒ PasswordStrength

Returns a new instance of PasswordStrength.

Parameters:

  • password_id (String)

    The ID for the password element that will be checked against

  • password_strength_tests (Array<Hash>)

    An array of options for the password strength tests, See Test#initialize for details of the items in the array.

  • options (Hash)

    a customizable set of options



29
30
31
32
33
34
35
# File 'lib/ccs/components/ccs/password_strength.rb', line 29

def initialize(password_id:, password_strength_tests:, **)
  super(**)

  @options[:attributes][:data][:target] = password_id

  @password_strength_tests = password_strength_tests.map { |password_strength_test| Test.new(context: @context, **password_strength_test) }
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the CCS password strength component

Returns:

  • (ActiveSupport::SafeBuffer)


41
42
43
44
45
# File 'lib/ccs/components/ccs/password_strength.rb', line 41

def render
  tag.ul(**options[:attributes]) do
    password_strength_tests.each { |password_strength_test| concat(password_strength_test.render) }
  end
end