Module: TestProf::FactoryDefault
- Defined in:
- lib/test_prof/factory_default.rb,
lib/test_prof/factory_default/factory_bot_patch.rb
Overview
Defined Under Namespace
Modules: DefaultSyntax, RunnerExt, StrategyExt
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.preserve_traits ⇒ Object
Returns the value of attribute preserve_traits.
25
26
27
|
# File 'lib/test_prof/factory_default.rb', line 25
def preserve_traits
@preserve_traits
end
|
Class Method Details
.get(name, traits = nil) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/test_prof/factory_default.rb', line 45
def get(name, traits = nil)
record = store[name]
return unless record
if traits && !traits.empty?
return if FactoryDefault.preserve_traits || record[:preserve_traits]
end
record[:object]
end
|
.register(name, obj, **options) ⇒ Object
39
40
41
42
43
|
# File 'lib/test_prof/factory_default.rb', line 39
def register(name, obj, **options)
options[:preserve_traits] = true if FactoryDefault.preserve_traits
store[name] = { object: obj, **options }
obj
end
|
.remove(name) ⇒ Object
55
56
57
|
# File 'lib/test_prof/factory_default.rb', line 55
def remove(name)
store.delete(name)
end
|
.reset ⇒ Object
59
60
61
|
# File 'lib/test_prof/factory_default.rb', line 59
def reset
@store.clear
end
|