lib/scaffolding_extensions.rb
# Takes two options, :only and :except.  If :only is given, :except is ignored.  Either
# can contain model classes or underscored model name strings.
Takes two options, :only and :except.  If :only is given, :except is ignored.  Either
can contain model classes or underscored model name strings.
Takes two options : only and : except . If : only is given : except is ignored . Either can contain model classes or underscored model name strings .
def all_models(options={})
      return @all_models if @all_models
      if options[:only]
        Array(options[:only]).collect{|f| f.is_a?(String) ? f.camelize.constantize : f}
      else
        string_except, except = Array(options[:except]).partition{|f| f.is_a?(String)}
        model_files.collect{|file|File.basename(file).sub(/\.rb\z/, '')}.
         reject{|f| string_except.include?(f)}.
         map{|f| f.camelize.constantize}.
         reject{|m| except.include?(m) || !MODEL_SUPERCLASSES.any?{|klass| m.ancestors.include?(klass)}}
      end
    end
def all_models ( options = { } ) return @all_models if @all_models if options [ :only ] Array ( options [ :only ] ) . collect { | f | f . is_a? ( String ) ? f . camelize . constantize : f } else string_except , except = Array ( options [ :except ] ) . partition { | f | f . is_a? ( String ) } model_files . collect { | file | File . basename ( file ) . sub ( / \. rb \z / , '' ) } . reject { | f | string_except . include? ( f ) } . map { | f | f . camelize . constantize } . reject { | m | except . include? ( m ) || ! MODEL_SUPERCLASSES . any? { | klass | m . ancestors . include? ( klass ) } } end end
Takes two options, :only and :except.
Takes two options : only and : except .
options
<not_specific>