Class: Administrate::BaseDashboard
- Inherits:
-
Object
- Object
- Administrate::BaseDashboard
- Includes:
- Administrate
- Defined in:
- lib/administrate/base_dashboard.rb
Constant Summary collapse
- DASHBOARD_SUFFIX =
"Dashboard".freeze
Constants included from Administrate
Class Method Summary collapse
Instance Method Summary collapse
- #all_attributes ⇒ Object
- #attribute_type_for(attribute_name) ⇒ Object
- #attribute_types ⇒ Object
- #attribute_types_for(attribute_names) ⇒ Object
- #collection_attributes ⇒ Object
- #collection_includes ⇒ Object
- #display_resource(resource) ⇒ Object
- #form_attributes ⇒ Object
- #item_includes ⇒ Object
- #permitted_attributes ⇒ Object
- #show_page_attributes ⇒ Object
Class Method Details
.model ⇒ Object
24 25 26 |
# File 'lib/administrate/base_dashboard.rb', line 24 def model to_s.chomp(DASHBOARD_SUFFIX).classify.constantize end |
.resource_name(opts) ⇒ Object
28 29 30 |
# File 'lib/administrate/base_dashboard.rb', line 28 def resource_name(opts) model.model_name.human(opts) end |
Instance Method Details
#all_attributes ⇒ Object
49 50 51 |
# File 'lib/administrate/base_dashboard.rb', line 49 def all_attributes attribute_types.keys end |
#attribute_type_for(attribute_name) ⇒ Object
37 38 39 40 41 |
# File 'lib/administrate/base_dashboard.rb', line 37 def attribute_type_for(attribute_name) attribute_types.fetch(attribute_name) do fail (attribute_name) end end |
#attribute_types ⇒ Object
33 34 35 |
# File 'lib/administrate/base_dashboard.rb', line 33 def attribute_types self.class::ATTRIBUTE_TYPES end |
#attribute_types_for(attribute_names) ⇒ Object
43 44 45 46 47 |
# 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 ⇒ Object
67 68 69 |
# File 'lib/administrate/base_dashboard.rb', line 67 def collection_attributes self.class::COLLECTION_ATTRIBUTES end |
#collection_includes ⇒ Object
75 76 77 |
# File 'lib/administrate/base_dashboard.rb', line 75 def collection_includes attribute_includes(collection_attributes) end |
#display_resource(resource) ⇒ Object
71 72 73 |
# File 'lib/administrate/base_dashboard.rb', line 71 def display_resource(resource) "#{resource.class} ##{resource.id}" end |
#form_attributes ⇒ Object
53 54 55 |
# File 'lib/administrate/base_dashboard.rb', line 53 def form_attributes self.class::FORM_ATTRIBUTES end |
#item_includes ⇒ Object
79 80 81 |
# File 'lib/administrate/base_dashboard.rb', line 79 def item_includes attribute_includes(show_page_attributes) end |
#permitted_attributes ⇒ Object
57 58 59 60 61 |
# 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 ⇒ Object
63 64 65 |
# File 'lib/administrate/base_dashboard.rb', line 63 def show_page_attributes self.class::SHOW_PAGE_ATTRIBUTES end |