Sha256: e9479adbaf103ffef1c5bce1548ee0e133bdc9d91ab59ab91c76cd41f8b3ebe7

Contents?: true

Size: 720 Bytes

Versions: 62

Compression:

Stored size: 720 Bytes

Contents

module Workarea
  class Content
    class Fieldset
      include AssetLookup

      attr_reader :fields
      attr_accessor :field_suffix, :name

      def initialize(name)
        @name = name
        @fields = []
      end

      def field(name, type, options = {})
        name = [name, field_suffix].join if field_suffix.present?

        klass = if type.is_a?(Class)
                  type
                else
                  "Workarea::Content::Fields::#{type.to_s.camelize}".constantize
                end

        if existing = @fields.detect { |f| f.name == name }
          existing.options.merge!(options)
        else
          @fields << klass.new(name, options)
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/content/fieldset.rb
workarea-core-3.5.26 app/models/workarea/content/fieldset.rb
workarea-core-3.4.45 app/models/workarea/content/fieldset.rb
workarea-core-3.5.25 app/models/workarea/content/fieldset.rb
workarea-core-3.5.23 app/models/workarea/content/fieldset.rb
workarea-core-3.4.44 app/models/workarea/content/fieldset.rb
workarea-core-3.5.22 app/models/workarea/content/fieldset.rb
workarea-core-3.4.43 app/models/workarea/content/fieldset.rb
workarea-core-3.5.21 app/models/workarea/content/fieldset.rb
workarea-core-3.4.42 app/models/workarea/content/fieldset.rb
workarea-core-3.5.20 app/models/workarea/content/fieldset.rb
workarea-core-3.4.41 app/models/workarea/content/fieldset.rb
workarea-core-3.5.19 app/models/workarea/content/fieldset.rb
workarea-core-3.4.40 app/models/workarea/content/fieldset.rb
workarea-core-3.5.18 app/models/workarea/content/fieldset.rb
workarea-core-3.4.39 app/models/workarea/content/fieldset.rb
workarea-core-3.5.17 app/models/workarea/content/fieldset.rb
workarea-core-3.4.38 app/models/workarea/content/fieldset.rb
workarea-core-3.5.16 app/models/workarea/content/fieldset.rb
workarea-core-3.4.37 app/models/workarea/content/fieldset.rb