Sha256: 84de2d5ff2e4f5331b42a59518b16bf63863d84c7142aee2df511e2affa57e06

Contents?: true

Size: 985 Bytes

Versions: 4

Compression:

Stored size: 985 Bytes

Contents

require "administrate/fields/belongs_to"
require "administrate/fields/email"
require "administrate/fields/has_many"
require "administrate/fields/image"
require "administrate/fields/string"

module Administrate
  class BaseDashboard
    def permitted_attributes
      form_attributes.map do |attr|
        field_class(attr).permitted_attribute(attr)
      end.uniq
    end

    def field_class(attr)
      field_registry.fetch(attribute_types[attr])
    end

    private

    def field_registry
      {
        belongs_to: Administrate::Field::BelongsTo,
        boolean: Administrate::Field::String,
        datetime: Administrate::Field::String,
        email: Administrate::Field::Email,
        float: Administrate::Field::String,
        has_many: Administrate::Field::HasMany,
        image: Administrate::Field::Image,
        integer: Administrate::Field::String,
        string: Administrate::Field::String,
        text: Administrate::Field::String,
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
administrate-0.0.6 lib/administrate/base_dashboard.rb
administrate-0.0.4 lib/administrate/base_dashboard.rb
administrate-0.0.3 lib/administrate/base_dashboard.rb
administrate-0.0.2 lib/administrate/base_dashboard.rb