Module: Fabricators
- Extended by:
- Methods
- Defined in:
- lib/fabricators.rb,
lib/fabricators/proxy.rb,
lib/fabricators/fetcher.rb,
lib/fabricators/methods.rb,
lib/fabricators/railtie.rb,
lib/fabricators/version.rb,
lib/fabricators/sequence.rb,
lib/fabricators/callbacks.rb,
lib/fabricators/fabricator.rb,
lib/fabricators/definitions.rb,
lib/fabricators/configuration.rb,
lib/generators/fabricators/model/model_generator.rb
Defined Under Namespace
Modules: Callbacks, Generators, Methods
Classes: Configuration, Definitions, Fabricator, Fetcher, Proxy, Railtie, Sequence
Constant Summary
collapse
- VERSION =
'0.1.2'
Class Method Summary
collapse
Class Method Details
.clean ⇒ Object
36
37
38
|
# File 'lib/fabricators.rb', line 36
def clean
records.pop.destroy until records.empty?
end
|
.configuration ⇒ Object
24
25
26
|
# File 'lib/fabricators.rb', line 24
def configuration
@configuration ||= Configuration.new
end
|
20
21
22
|
# File 'lib/fabricators.rb', line 20
def configure(&block)
configuration.instance_eval &block
end
|
.define(&block) ⇒ Object
28
29
30
|
# File 'lib/fabricators.rb', line 28
def define(&block)
definitions.instance_eval &block
end
|
.definitions ⇒ Object
32
33
34
|
# File 'lib/fabricators.rb', line 32
def definitions
@definitions ||= Definitions.new
end
|
.load ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/fabricators.rb', line 44
def load
if path
Dir[path.join('**', '*.rb')].each do |file|
definitions.instance_eval File.read(file)
end
end
end
|
.path ⇒ Object
52
53
54
|
# File 'lib/fabricators.rb', line 52
def path
@path ||= %w(test spec).map{ |dir| Rails.root.join(dir) }.find{ |path| Dir.exist?(path) }.try(:join, 'fabricators')
end
|
.records ⇒ Object
40
41
42
|
# File 'lib/fabricators.rb', line 40
def records
@records ||= []
end
|
.reset ⇒ Object
15
16
17
18
|
# File 'lib/fabricators.rb', line 15
def reset
configuration.reset
definitions.reset
end
|