Class: Administrate::BaseDashboard

Inherits:
Object
  • Object
show all
Includes:
Administrate
Defined in:
lib/administrate/base_dashboard.rb

Constant Summary

Constants included from Administrate

VERSION

Instance Method Summary collapse

Instance Method Details

#all_attributesObject



35
36
37
# File 'lib/administrate/base_dashboard.rb', line 35

def all_attributes
  attribute_types.keys
end

#association_includesObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/administrate/base_dashboard.rb', line 61

def association_includes
  association_classes = [Field::HasMany, Field::HasOne, Field::BelongsTo]

  collection_attributes.map do |key|
    field = self.class::ATTRIBUTE_TYPES[key]

    next key if association_classes.include?(field)
    key if association_classes.include?(field.try(:deferred_class))
  end.compact
end

#attribute_type_for(attribute_name) ⇒ Object



23
24
25
26
27
# File 'lib/administrate/base_dashboard.rb', line 23

def attribute_type_for(attribute_name)
  attribute_types.fetch(attribute_name) do
    fail attribute_not_found_message(attribute_name)
  end
end

#attribute_typesObject



19
20
21
# File 'lib/administrate/base_dashboard.rb', line 19

def attribute_types
  self.class::ATTRIBUTE_TYPES
end

#attribute_types_for(attribute_names) ⇒ Object



29
30
31
32
33
# File 'lib/administrate/base_dashboard.rb', line 29

def attribute_types_for(attribute_names)
  attribute_names.each_with_object({}) do |name, attributes|
    attributes[name] = attribute_type_for(name)
  end
end

#collection_attributesObject



53
54
55
# File 'lib/administrate/base_dashboard.rb', line 53

def collection_attributes
  self.class::COLLECTION_ATTRIBUTES
end

#display_resource(resource) ⇒ Object



57
58
59
# File 'lib/administrate/base_dashboard.rb', line 57

def display_resource(resource)
  "#{resource.class} ##{resource.id}"
end

#form_attributesObject



39
40
41
# File 'lib/administrate/base_dashboard.rb', line 39

def form_attributes
  self.class::FORM_ATTRIBUTES
end

#permitted_attributesObject



43
44
45
46
47
# File 'lib/administrate/base_dashboard.rb', line 43

def permitted_attributes
  form_attributes.map do |attr|
    attribute_types[attr].permitted_attribute(attr)
  end.uniq
end

#show_page_attributesObject



49
50
51
# File 'lib/administrate/base_dashboard.rb', line 49

def show_page_attributes
  self.class::SHOW_PAGE_ATTRIBUTES
end