class GatherContent::Config::Element::ChoiceCheckbox
Attributes
options[RW]
Public Class Methods
new(name = "", required = false, label = "", microcopy = "")
click to toggle source
Calls superclass method
GatherContent::Config::Element::Base::new
# File lib/gather_content/config/elements/choice_checkbox.rb, line 10 def initialize(name = "", required = false, label = "", microcopy = "") super(name, required, label, microcopy) @options = [] end
Public Instance Methods
serialize(_options = nil)
click to toggle source
Calls superclass method
GatherContent::Config::Element::Base#serialize
# File lib/gather_content/config/elements/choice_checkbox.rb, line 15 def serialize(_options = nil) cleaned = options.select{ |opt| opt.instance_of?(GatherContent::Config::Element::Option) } raise ArgumentError, "You need to supply at least one option" if options.size == 0 raise ArgumentError, "Options can only be GatherContent::Config::Element::Option" if cleaned.size == 0 super.merge({ type: 'choice_checkbox', options: options.map{ |el| el.serialize(_options) } }) end
to_json()
click to toggle source
# File lib/gather_content/config/elements/choice_checkbox.rb, line 26 def to_json serialize.to_json end