Module: Kitsune

Defined in:
lib/kitsune.rb,
lib/kitsune/page.rb,
lib/kitsune/builder.rb,
lib/kitsune/inspector.rb,
lib/kitsune/faux_column.rb,
lib/kitsune/mongo_mapper.rb,
lib/kitsune/active_record.rb

Defined Under Namespace

Modules: ActiveRecord, MongoMapper, Page Classes: Builder, FauxColumn, Inspector, TypeError

Class Method Summary collapse

Class Method Details

.authenticateObject



14
15
16
# File 'lib/kitsune.rb', line 14

def authenticate
  @authenticate ||= false
end

.authenticate=(do_authenticate) ⇒ Object



18
19
20
# File 'lib/kitsune.rb', line 18

def authenticate=(do_authenticate)
  @authenticate = do_authenticate
end

.model_pathsObject

abstract this to something else



22
23
24
# File 'lib/kitsune.rb', line 22

def model_paths # abstract this to something else
  @models_paths ||= ["#{RAILS_ROOT}/app/models"]
end

.model_paths=(paths) ⇒ Object



26
27
28
# File 'lib/kitsune.rb', line 26

def model_paths=(paths)
  @model_paths = paths
end

.modelsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/kitsune.rb', line 34

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

.models_with_adminObject



30
31
32
# File 'lib/kitsune.rb', line 30

def models_with_admin
  models.select{|m| m.respond_to?(:kitsune_admin) && !m.kitsune_admin[:no_admin]} # quacks like a duck
end

.versionObject



10
11
12
# File 'lib/kitsune.rb', line 10

def version
  '0.1.2'
end