Method: Primer::Forms::Dsl::CheckBoxInput#initialize

Defined in:
app/lib/primer/forms/dsl/check_box_input.rb

#initialize(name:, label:, value: nil, unchecked_value: nil, scheme: DEFAULT_SCHEME, **system_arguments) {|_self| ... } ⇒ CheckBoxInput

Returns a new instance of CheckBoxInput.

Yields:

  • (_self)

Yield Parameters:

Raises:

  • (ArgumentError)
[View source]

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/lib/primer/forms/dsl/check_box_input.rb', line 13

def initialize(name:, label:, value: nil, unchecked_value: nil, scheme: DEFAULT_SCHEME, **system_arguments)
  raise ArgumentError, "Check box scheme must be one of #{SCHEMES.join(', ')}" unless SCHEMES.include?(scheme)

  raise ArgumentError, "Check box needs an explicit value if scheme is array" if scheme == :array && value.nil?

  @name = name
  @label = label
  @value = value
  @unchecked_value = unchecked_value
  @scheme = scheme

  super(**system_arguments)

  yield(self) if block_given?
end