Class: Administrate::BaseDashboard
- Inherits:
-
Object
- Object
- Administrate::BaseDashboard
- Includes:
- Administrate
- Defined in:
- lib/administrate/base_dashboard.rb
Constant Summary
Constants included from Administrate
Instance Method Summary collapse
- #all_attributes ⇒ Object
- #association_includes ⇒ Object
- #attribute_type_for(attribute_name) ⇒ Object
- #attribute_types ⇒ Object
- #attribute_types_for(attribute_names) ⇒ Object
- #collection_attributes ⇒ Object
- #display_resource(resource) ⇒ Object
- #form_attributes ⇒ Object
- #permitted_attributes ⇒ Object
- #show_page_attributes ⇒ Object
Instance Method Details
#all_attributes ⇒ Object
35 36 37 |
# File 'lib/administrate/base_dashboard.rb', line 35 def all_attributes attribute_types.keys end |
#association_includes ⇒ Object
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_name) end end |
#attribute_types ⇒ Object
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_attributes ⇒ Object
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_attributes ⇒ Object
39 40 41 |
# File 'lib/administrate/base_dashboard.rb', line 39 def form_attributes self.class::FORM_ATTRIBUTES end |
#permitted_attributes ⇒ Object
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_attributes ⇒ Object
49 50 51 |
# File 'lib/administrate/base_dashboard.rb', line 49 def show_page_attributes self.class::SHOW_PAGE_ATTRIBUTES end |