Module: Fabricators

Extended by:
Methods
Defined in:
lib/fabricators.rb,
lib/fabricators/proxy.rb,
lib/fabricators/reader.rb,
lib/fabricators/methods.rb,
lib/fabricators/railtie.rb,
lib/fabricators/version.rb,
lib/fabricators/callbacks.rb,
lib/fabricators/generator.rb,
lib/fabricators/fabricator.rb,
lib/fabricators/definitions.rb,
lib/generators/fabricators/model/model_generator.rb

Defined Under Namespace

Modules: Callbacks, Generators, Methods Classes: Definitions, Fabricator, Generator, Proxy, Railtie, Reader

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.define(&block) ⇒ Object



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

def define(&block)
  definitions.instance_eval &block
end

.definitionsObject



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

def definitions
  @definitions ||= Definitions.new
end

.generate(name) ⇒ Object



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

def generate(name)
  definitions.find(name, :generator).generate
end

.pathObject



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

def path
  @path ||= paths.find { |path| Dir.exists? path }
end

.pathsObject



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

def paths
  @paths ||= %w(test/fabricators spec/fabricators).map { |path| Rails.root.join(path) }
end

.populateObject



34
35
36
37
38
# File 'lib/fabricators.rb', line 34

def populate
  Dir[path.join('**', '*.rb')].each do |file|
    load file
  end
end