diff --git a/lib/abstract_model.rb b/lib/abstract_model.rb index 0102cda..d36c9b0 100644 --- a/lib/abstract_model.rb +++ b/lib/abstract_model.rb @@ -11,22 +11,26 @@ def self.all when :activerecord, :sequel Dir.glob(Merb.dir_for(:model) / Merb.glob_for(:model)).each do |filename| File.read(filename).scan(/class ([\w\d_\-:]+)/).flatten.each do |model_name| - model = lookup(model_name.to_sym) - @models << new(model) if model + add_model(model_name.to_sym) end end when :datamapper DataMapper::Model.descendants.each do |model_name| # Remove DataMapperSessionStore because it's included by default next if m == Merb::DataMapperSessionStore if Merb.const_defined?(:DataMapperSessionStore) - model = lookup(model_name.to_s.to_sym) - @models << new(model) if model + add_model(model_name.to_s.to_sym) end else raise "MerbAdmin does not support the #{orm} ORM" end @models.sort!{|x, y| x.model.to_s <=> y.model.to_s} end + + def self.add_model(name) + return if Merb::Slices.config[:merb_admin][:excluded_models].include?(name.to_s.snake_case.to_sym) + model = lookup(name) + @models << new(model) if model + end # Given a symbol +model_name+, finds the corresponding model class def self.lookup(model_name) diff --git a/lib/merb-admin.rb b/lib/merb-admin.rb index 90f16ca..d0832ce 100644 --- a/lib/merb-admin.rb +++ b/lib/merb-admin.rb @@ -17,6 +17,7 @@ # :mirror - which path component types to use on copy operations; defaults to all Merb::Slices::config[:merb_admin][:layout] ||= :merb_admin Merb::Slices::config[:merb_admin][:per_page] ||= 100 + Merb::Slices::config[:merb_admin][:excluded_models] ||= [] # All Slice code is expected to be namespaced inside a module module MerbAdmin