class Administrate::BaseDashboard

Constants

DASHBOARD_SUFFIX

Public Class Methods

model() click to toggle source
# File lib/administrate/base_dashboard.rb, line 24
def model
  to_s.chomp(DASHBOARD_SUFFIX).classify.constantize
end
resource_name(opts) click to toggle source
# File lib/administrate/base_dashboard.rb, line 28
def resource_name(opts)
  model.model_name.human(opts)
end

Public Instance Methods

all_attributes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 49
def all_attributes
  attribute_types.keys
end
attribute_type_for(attribute_name) click to toggle source
# File lib/administrate/base_dashboard.rb, line 37
def attribute_type_for(attribute_name)
  attribute_types.fetch(attribute_name) do
    fail attribute_not_found_message(attribute_name)
  end
end
attribute_types() click to toggle source
# File lib/administrate/base_dashboard.rb, line 33
def attribute_types
  self.class::ATTRIBUTE_TYPES
end
attribute_types_for(attribute_names) click to toggle source
# File lib/administrate/base_dashboard.rb, line 43
def attribute_types_for(attribute_names)
  attribute_names.each_with_object({}) do |name, attributes|
    attributes[name] = attribute_type_for(name)
  end
end
collection_attributes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 67
def collection_attributes
  self.class::COLLECTION_ATTRIBUTES
end
collection_includes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 75
def collection_includes
  attribute_includes(collection_attributes)
end
display_resource(resource) click to toggle source
# File lib/administrate/base_dashboard.rb, line 71
def display_resource(resource)
  "#{resource.class} ##{resource.id}"
end
form_attributes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 53
def form_attributes
  self.class::FORM_ATTRIBUTES
end
item_includes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 79
def item_includes
  attribute_includes(show_page_attributes)
end
permitted_attributes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 57
def permitted_attributes
  form_attributes.map do |attr|
    attribute_types[attr].permitted_attribute(attr)
  end.uniq
end
show_page_attributes() click to toggle source
# File lib/administrate/base_dashboard.rb, line 63
def show_page_attributes
  self.class::SHOW_PAGE_ATTRIBUTES
end

Private Instance Methods

attribute_includes(attributes) click to toggle source
# File lib/administrate/base_dashboard.rb, line 89
def attribute_includes(attributes)
  attributes.map do |key|
    field = self.class::ATTRIBUTE_TYPES[key]

    key if field.associative?
  end.compact
end
attribute_not_found_message(attr) click to toggle source
# File lib/administrate/base_dashboard.rb, line 85
def attribute_not_found_message(attr)
  "Attribute #{attr} could not be found in #{self.class}::ATTRIBUTE_TYPES"
end