Sha256: fed4246f995fb832021161c9796a456819805d203d8a9167f0be38ecb04ef0da
Contents?: true
Size: 1.07 KB
Versions: 28
Compression:
Stored size: 1.07 KB
Contents
module Workarea module Configuration module Administrable class Fieldset attr_accessor :fields, :name def initialize(name, namespaced: true) @name = name @namespaced = namespaced @fields = SwappableList.new end def id name.to_s.systemize.to_sym end def namespaced? @namespaced end def field(name, type: nil, override: false, **options) field = Field.new(name, fieldset: self, type: type, **options) existing = find_field(field.id) if existing.present? && override @fields.swap(existing, field.validate!) elsif existing.present? existing.merge!(options) existing.validate! else @fields.push(field.validate!) end return unless field.encrypted? Rails.application.config.filter_parameters << field.key end def find_field(id) @fields.detect { |field| field.id == id.to_sym } end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems