Class: Primer::Forms::Dsl::SelectInput

Inherits:
Input
  • Object
show all
Defined in:
lib/ariadne/forms/dsl/select_input.rb

Overview

:nodoc:

Constant Summary collapse

SELECT_ARGUMENTS =
[:multiple, :include_blank, :include_hidden, :prompt].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, label:, **options) {|_self| ... } ⇒ SelectInput

Returns a new instance of SelectInput.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ariadne/forms/dsl/select_input.rb', line 12

def initialize(name:, label:, **options)
  @name = name
  @label = label
  @options = []

  @select_arguments = {}.tap do |select_args|
    SELECT_ARGUMENTS.each do |select_arg|
      select_args[select_arg] = options.delete(select_arg)
    end
  end

  super(**options)

  yield(self) if block_given?
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



10
11
12
# File 'lib/ariadne/forms/dsl/select_input.rb', line 10

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/ariadne/forms/dsl/select_input.rb', line 10

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/ariadne/forms/dsl/select_input.rb', line 10

def options
  @options
end

#select_argumentsObject (readonly)

Returns the value of attribute select_arguments.



10
11
12
# File 'lib/ariadne/forms/dsl/select_input.rb', line 10

def select_arguments
  @select_arguments
end

Instance Method Details

#focusable?Boolean

:nocov:

Returns:

  • (Boolean)


43
44
45
# File 'lib/ariadne/forms/dsl/select_input.rb', line 43

def focusable?
  true
end

#multiple?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ariadne/forms/dsl/select_input.rb', line 28

def multiple?
  @select_arguments.fetch(:multiple, false)
end

#to_componentObject



32
33
34
# File 'lib/ariadne/forms/dsl/select_input.rb', line 32

def to_component
  Ariadne::Form::Select::Component.new(name:, label:, **@options)
end

#typeObject

:nocov:



37
38
39
# File 'lib/ariadne/forms/dsl/select_input.rb', line 37

def type
  :select_list
end