Sha256: e6bc25e9a9a8bf2973c6b002c439798b7836e75aebe162d0220dd8397e0d14b9

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 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.1.2'
    end
    
    def authenticate
      @authenticate ||= false
    end
    
    def authenticate=(do_authenticate)
      @authenticate = do_authenticate
    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 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
            if defined? ::ActiveRecord
              models << klass if klass.ancestors.include?(::ActiveRecord::Base)
            else defined? ::MongoMapper
              models << klass if klass.ancestors.include?(::MongoMapper::Document)
            end
          rescue Exception => e
            # not valid
          end
        end
      end
      models
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kitsune-0.1.5 lib/kitsune.rb
kitsune-0.1.4 lib/kitsune.rb
kitsune-0.1.3 lib/kitsune.rb
kitsune-0.1.2 lib/kitsune.rb