lib/administrate/base_dashboard.rb in administrate-0.13.0 vs lib/administrate/base_dashboard.rb in administrate-0.14.0
- old
+ new
@@ -16,10 +16,22 @@
module Administrate
class BaseDashboard
include Administrate
+ DASHBOARD_SUFFIX = "Dashboard".freeze
+
+ class << self
+ def model
+ to_s.chomp(DASHBOARD_SUFFIX).classify.constantize
+ end
+
+ def resource_name(opts)
+ model.model_name.human(opts)
+ end
+ end
+
def attribute_types
self.class::ATTRIBUTE_TYPES
end
def attribute_type_for(attribute_name)
@@ -72,21 +84,14 @@
def attribute_not_found_message(attr)
"Attribute #{attr} could not be found in #{self.class}::ATTRIBUTE_TYPES"
end
- def association_classes
- @association_classes ||=
- ObjectSpace.each_object(Class).
- select { |klass| klass < Administrate::Field::Associative }
- end
-
def attribute_includes(attributes)
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))
+ key if field.associative?
end.compact
end
end
end