Sha256: 074b5c86c405f694c30704b254f80c041274a845a0bcff832b7e1daee318677f
Contents?: true
Size: 730 Bytes
Versions: 19
Compression:
Stored size: 730 Bytes
Contents
module Avo module Fields class BooleanGroupField < BaseField attr_reader :options def initialize(id, **args, &block) super(id, **args, &block) @options = args[:options].present? ? args[:options] : {} end def to_permitted_param ["#{id}": []] end def fill_field(model, key, value) new_value = {} # Filter out the empty ("") value boolean group generates value = value.filter do |arr_value| arr_value.present? end # Cast values to booleans options.each do |id, label| new_value[id] = value.include? id.to_s end model[id] = new_value model end end end end
Version data entries
19 entries across 19 versions & 1 rubygems