Sha256: 5cc6292e5f8cc03d98d499ada216bd38f6f37c279540c9a323611826e1aba6f6
Contents?: true
Size: 1.18 KB
Versions: 28
Compression:
Stored size: 1.18 KB
Contents
module Workarea module Configuration module Administrable class Definition attr_reader :fieldsets delegate :field, to: :application_fieldset def initialize @fieldsets = SwappableList.new @fieldsets.push(Fieldset.new('Application', namespaced: false)) end def fieldset(name, override: false, namespaced: true, &block) fieldset = Fieldset.new(name, namespaced: namespaced) existing = find_fieldset(fieldset.id) if override && existing.present? @fieldsets.swap(existing, fieldset) fieldset.instance_eval(&block) if block_given? elsif existing.present? existing.instance_eval(&block) if block_given? else @fieldsets.push(fieldset) fieldset.instance_eval(&block) if block_given? end end def application_fieldset @application_fieldset ||= find_fieldset(:application) end def find_fieldset(id) @fieldsets.detect { |fieldset| fieldset.id == id.to_sym } end def fields @fieldsets.flat_map(&:fields) end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems