Class: Wizardry::Questions::Radios
- Defined in:
- lib/wizardry/questions/radios.rb
Defined Under Namespace
Classes: RadioOption
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Answer
Instance Method Summary collapse
- #build_options ⇒ Object
- #extra_args ⇒ Object
- #form_method ⇒ Object
-
#initialize(name, options) ⇒ Radios
constructor
A new instance of Radios.
Methods inherited from Answer
Constructor Details
#initialize(name, options) ⇒ Radios
Returns a new instance of Radios.
8 9 10 11 12 13 14 |
# File 'lib/wizardry/questions/radios.rb', line 8 def initialize(name, ) Rails.logger.debug("🧙 Adding radios '#{name}' with options #{}") @options = super(name) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/wizardry/questions/radios.rb', line 4 def @options end |
Instance Method Details
#build_options ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wizardry/questions/radios.rb', line 24 def case when Array .map { |v| Wizardry::Questions::Radios::RadioOption.new(value: v, label: v) } when Hash .map { |k, v| Wizardry::Questions::Radios::RadioOption.new(value: k, label: v) } else fail ArgumentError, "Options must be an Hash or Array" end end |
#extra_args ⇒ Object
20 21 22 |
# File 'lib/wizardry/questions/radios.rb', line 20 def extra_args [, :value, :label] end |
#form_method ⇒ Object
16 17 18 |
# File 'lib/wizardry/questions/radios.rb', line 16 def form_method :govuk_collection_radio_buttons end |