factory_girl-cache 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -5
- data/lib/factory_girl-cache/cache.rb +2 -2
- data/lib/factory_girl-cache/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -27,14 +27,11 @@ To clear the cache:
|
|
27
27
|
|
28
28
|
This may seem completely odd, e.g. creating something would imply really creating a new instance, as would building. And you'll get the same id back. Why would you want to do that?
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
SystemStackError:
|
33
|
-
stack level too deep
|
30
|
+
Originally, the idea was that this could be used to avoid circular references, but there are other complexities in factory interdependencies that keep the cache alone from being a silver bullet for those issues. However, for some cases it could still significantly speed up accessing factory created instances, if you are careful.
|
34
31
|
|
35
32
|
This gem should not affect FactoryGirl itself. It just provides an alternate way to use FactoryGirl that makes it behave a bit differently.
|
36
33
|
|
37
|
-
Please understand what you are doing by using this.
|
34
|
+
Please understand what you are doing by using this. Handle it carefully and don't shoot yourself with it!
|
38
35
|
|
39
36
|
### Installation
|
40
37
|
|
@@ -13,9 +13,9 @@ module FactoryGirlCache
|
|
13
13
|
keys = args.dup
|
14
14
|
args.delete_at(1) if args.size > 1 && args[1].is_a?(Symbol)
|
15
15
|
@factory_girl_cache ||= {}
|
16
|
-
@factory_girl_cache[[m, *keys]] ||=
|
16
|
+
@factory_girl_cache[[m, *keys]] ||= FactoryGirl.__send__(m, *args, &block)
|
17
17
|
else
|
18
|
-
|
18
|
+
FactoryGirl.__send__(m, *args, &block)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|