Sha256: eed0ad0338d67011ac4d8206f3e1b6eb5e8be1751a406dcb534fe0b41bf9400a
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
require "administrate/fields/belongs_to" require "administrate/fields/boolean" require "administrate/fields/date_time" require "administrate/fields/email" require "administrate/fields/has_many" require "administrate/fields/has_one" require "administrate/fields/image" require "administrate/fields/number" require "administrate/fields/polymorphic" require "administrate/fields/string" require "administrate/fields/text" module Administrate class BaseDashboard include Administrate def attribute_types self.class::ATTRIBUTE_TYPES end def attribute_type_for(attribute_name) attribute_types.fetch(attribute_name) do fail attribute_not_found_message(attribute_name) end end def attribute_types_for(attribute_names) attribute_names.each_with_object({}) do |name, attributes| attributes[name] = attribute_type_for(name) end end def form_attributes self.class::FORM_ATTRIBUTES end def permitted_attributes form_attributes.map do |attr| attribute_types[attr].permitted_attribute(attr) end.uniq end def show_page_attributes self.class::SHOW_PAGE_ATTRIBUTES end def collection_attributes self.class::COLLECTION_ATTRIBUTES end def display_resource(resource) "#{resource.class} ##{resource.id}" end private def attribute_not_found_message(attr) "Attribute #{attr} could not be found in #{self.class}::ATTRIBUTE_TYPES" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
administrate-0.1.3 | lib/administrate/base_dashboard.rb |
administrate-0.1.2 | lib/administrate/base_dashboard.rb |