lib/admin_it/resource.rb in admin_it-1.0.10 vs lib/admin_it/resource.rb in admin_it-1.0.11
- old
+ new
@@ -6,10 +6,11 @@
module AdminIt
class Resource
extend ExtendIt::Base
include ExtendIt::Callbacks
include ExtendIt::Dsl
+ include Defaults
include Iconed
include FieldsHolder
include FiltersHolder
dsl do
@@ -43,10 +44,28 @@
value = value.ensure_symbol
@contexts.key?(value) ? value : nil
end
end
+ defaults do
+ fields { puts "FIELDS"; [] }
+
+ filters { puts "FILTERS"; [] }
+
+ display_name do
+ puts "DISPLAY"
+ plural.split('_').map { |s| s.capitalize }.join(' ')
+ end
+
+ contexts do
+ CONTEXTS.map do |c|
+ context_class = AdminIt.const_get("#{c.capitalize}Context")
+ context_class.create(c, self)
+ end
+ end
+ end
+
attr_reader :name, :plural, :entity_class, :menu
define_callbacks :initialize
def initialize(
@@ -172,11 +191,10 @@
contexts.each { |c| c.controller_class = c_class }
end
protected
- # LAYOUTS = %w(content)
COLLECTIONS = %i(table tiles list)
SINGLE = %i(show new edit)
CONTEXTS = COLLECTIONS + SINGLE
def sanitize_entity_class
@@ -192,28 +210,9 @@
end
end
unless @entity_class.is_a?(Class)
fail ArgumentError, 'Wrong entity class'
end
- end
-
- def default_fields
- []
- end
-
- def default_contexts
- CONTEXTS.map do |c|
- context_class = AdminIt.const_get("#{c.capitalize}Context")
- context_class.create(c, self)
- end
- end
-
- def default_filters
- []
- end
-
- def default_display_name
- plural.split('_').map { |s| s.capitalize }.join(' ')
end
def i18n_display_name
begin
I18n