Skip to content

Commit

Permalink
Adds :excluded_models option to global config
Browse files Browse the repository at this point in the history
  • Loading branch information
jonuts authored and sferik committed Nov 12, 2009
1 parent 2569664 commit f6157d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/abstract_model.rb
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/merb-admin.rb
Expand Up @@ -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
Expand Down

0 comments on commit f6157d1

Please sign in to comment.