Class: GatherContent::Config::Element::ChoiceRadio
- Defined in:
- lib/gather_content/config/elements/choice_radio.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#other_option ⇒ Object
Returns the value of attribute other_option.
Attributes inherited from Base
#label, #microcopy, #name, #required
Instance Method Summary collapse
-
#initialize(name = "", required = false, label = "", microcopy = "", other_option = false) ⇒ ChoiceRadio
constructor
A new instance of ChoiceRadio.
- #serialize(_options = nil) ⇒ Object
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(name = "", required = false, label = "", microcopy = "", other_option = false) ⇒ ChoiceRadio
Returns a new instance of ChoiceRadio.
11 12 13 14 15 |
# File 'lib/gather_content/config/elements/choice_radio.rb', line 11 def initialize(name = "", required = false, label = "", microcopy = "", other_option = false) super(name, required, label, microcopy) @other_option = other_option @options = [] end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/gather_content/config/elements/choice_radio.rb', line 9 def @options end |
#other_option ⇒ Object
Returns the value of attribute other_option.
9 10 11 |
# File 'lib/gather_content/config/elements/choice_radio.rb', line 9 def other_option @other_option end |
Instance Method Details
#serialize(_options = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gather_content/config/elements/choice_radio.rb', line 17 def serialize( = nil) raise ArgumentError, "You need to supply at least one option" if .size == 0 if other_option verify_other_option_types!() else verify_option_types!() end () super.merge({ type: 'choice_radio', other_option: !!other_option, options: .map{ |el| el.serialize() } }) end |
#to_json(options = nil) ⇒ Object
35 36 37 |
# File 'lib/gather_content/config/elements/choice_radio.rb', line 35 def to_json( = nil) serialize.to_json() end |