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 85 def collection_attributes self.class::COLLECTION_ATTRIBUTES end
collection_includes()
click to toggle source
# File lib/administrate/base_dashboard.rb, line 99 def collection_includes attribute_includes(collection_attributes) end
display_resource(resource)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 95 def display_resource(resource) "#{resource.class} ##{resource.id}" end
form_attributes(action = nil)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 53 def form_attributes(action = nil) action = case action when "update" then "edit" when "create" then "new" else action end specific_form_attributes_for(action) || self.class::FORM_ATTRIBUTES end
item_associations()
click to toggle source
# File lib/administrate/base_dashboard.rb, line 109 def item_associations attribute_associated(show_page_attributes) end
item_includes()
click to toggle source
# File lib/administrate/base_dashboard.rb, line 103 def item_includes # Deprecated, internal usage has moved to #item_associations Administrate.warn_of_deprecated_method(self.class, :item_includes) attribute_includes(show_page_attributes) end
permitted_attributes(action = nil)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 71 def permitted_attributes(action = nil) form_attributes(action).map do |attr| attribute_types[attr].permitted_attribute( attr, resource_class: self.class.model, action: action, ) end.uniq end
search_attributes()
click to toggle source
# File lib/administrate/base_dashboard.rb, line 89 def search_attributes attribute_types.keys.select do |attribute| attribute_types[attribute].searchable? end end
show_page_attributes()
click to toggle source
# File lib/administrate/base_dashboard.rb, line 81 def show_page_attributes self.class::SHOW_PAGE_ATTRIBUTES end
specific_form_attributes_for(action)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 63 def specific_form_attributes_for(action) return unless action cname = "FORM_ATTRIBUTES_#{action.upcase}" self.class.const_get(cname) if self.class.const_defined?(cname) end
Private Instance Methods
attribute_associated(attributes)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 127 def attribute_associated(attributes) attributes.map do |key| field = attribute_type_for(key) key if field.associative? end.compact end
attribute_includes(attributes)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 119 def attribute_includes(attributes) attributes.map do |key| field = attribute_type_for(key) key if field.eager_load? end.compact end
attribute_not_found_message(attr)
click to toggle source
# File lib/administrate/base_dashboard.rb, line 115 def attribute_not_found_message(attr) "Attribute #{attr} could not be found in #{self.class}::ATTRIBUTE_TYPES" end