Sha256: 8dd7201f31dfd8737f520c3c4341a92b33e21fb3a56ac5aa4f9c113a1a87f193

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'kitsune/active_record'
require 'kitsune/extensions/routes'
require 'kitsune/form_helper_ext'

module Kitsune
  autoload :FauxColumn, 'kitsune/faux_column'
  autoload :Inspector, 'kitsune/inspector'
  autoload :Page, 'kitsune/page'
  class << self
    def version
      '0.0.13'
    end
  
    def model_paths # abstract this to something else
      @models_paths ||= ["#{RAILS_ROOT}/app/models"]
    end
    
    def model_paths=(paths)
      @model_paths = paths
    end
    
    # def model_paths<<(path)
    #       @model_paths << path
    #     end
    
    def models_with_admin
      models.select{|m| m.respond_to?(:kitsune_admin) && !m.kitsune_admin[:no_admin]} # quacks like a duck
    end
    
    def models
      models = []
      model_paths.each do |path|
        Dir.glob(path+'/*').each do |file|
          begin
            klass = File.basename(file).gsub(/^(.+).rb/, '\1').classify.constantize
            models << klass if klass.ancestors.include?(::ActiveRecord::Base)
          rescue Exception => e
            # not valid
          end
        end
      end
      models
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kitsune-0.0.13 lib/kitsune.rb