Module: Mockumentary

Defined in:
lib/mockumentary.rb,
lib/mockumentary/data.rb,
lib/mockumentary/model.rb,
lib/mockumentary/collection.rb,
lib/mockumentary/active_record.rb

Defined Under Namespace

Modules: ActiveRecord, Data Classes: Collection, Model

Class Method Summary collapse

Class Method Details

.dump(dir = "#{Rails.root}/config") ⇒ Object



23
24
25
# File 'lib/mockumentary.rb', line 23

def self.dump dir = "#{Rails.root}/config"
  Mockery.dump
end

.introspect(dir = "#{Rails.root}/app/models", namespace = '') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mockumentary.rb', line 4

def self.introspect dir = "#{Rails.root}/app/models", namespace = ''
   Dir.chdir(dir) do 
    Dir['*.rb'].each do |file|
      require "#{dir}/#{file}"
      ar_class = (namespace + file.gsub(/\.rb$/, '').classify).constantize
      Mockery.generate(ar_class) rescue nil
    end

    Dir['*'].each do |file|
      path = "#{dir}/#{file}"
      if File.directory?(path)
        namespace << "::" unless namespace.empty?
        namespace << "#{file.classify}::"
        introspect(path, namespace)
      end
    end
  end 
end

.load(dir = nil) ⇒ Object



27
28
29
# File 'lib/mockumentary.rb', line 27

def self.load(dir=nil)
  Mocksimile.load(dir)
end

.load_and_release(dir = nil) ⇒ Object



31
32
33
34
# File 'lib/mockumentary.rb', line 31

def self.load_and_release(dir=nil)
  load(dir)
  Mocksimile.release
end