File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : factory
2- version : 0.1.2
2+ version : 0.1.3
33
44authors :
55 - Roman Kalnytskyi <moranibaca@gmail.com>
@@ -9,8 +9,8 @@ crystal: 0.24.1
99license : MIT
1010development_dependencies :
1111 minitest :
12- github : ysbaddaden/minitest.cr
13- version : " ~> 0.3.6 "
12+ github : ysbaddaden/minitest.cr
13+ version : " ~> 0.4.0 "
1414 # TODO: uncomment after resolving issue with migrating jennifer to 0.24.1 crystal
1515 # jennifer:
1616 # github: imdrasil/jennifer.cr
Original file line number Diff line number Diff line change @@ -2,24 +2,26 @@ module Factory
22 module Jennifer
33 macro association_macro
44 macro association (name , factory = nil , strategy = :create , options = nil )
5- \{% ASSOCIATIONS << name.id.stringify % }
6-
7- \{% if factory % }
8- \{% klass = factory % }
9- \{% else % }
10- \{% klass = (name.id.stringify.camelcase + " Factory" ).id% }
11- \{% end % }
12-
13- def self.__process_association_ \{{name.id}}(obj)
14- aobj = \{{klass}}.build(\{% if options % }\{{options}} \{% end % })
15- \{% if strategy.id.stringify == " build" % }
16- obj.append_\{{name.id}}(aobj)
17- \{% elsif strategy.id.stringify == " create" % }
18- obj.add_\{{name.id}}(aobj)
19- \{% else % }
20- \{% raise " Strategy #{ strategy.id } of #{ @type } is not valid" }
21- \{% end % }
22- end
5+ {% verbatim do % }
6+ {% ASSOCIATIONS << name.id.stringify % }
7+
8+ {% if factory % }
9+ {% klass = factory % }
10+ {% else % }
11+ {% klass = (name.id.stringify.camelcase + " Factory" ).id% }
12+ {% end % }
13+
14+ def self.__process_association_ \{{name.id}}(obj)
15+ aobj = {{klass}}.build({% if options % }{{options}} {% end % })
16+ {% if strategy.id.stringify == " build" % }
17+ obj.append_{{name.id}}(aobj)
18+ {% elsif strategy.id.stringify == " create" % }
19+ obj.add_{{name.id}}(aobj)
20+ {% else % }
21+ {% raise " Strategy #{ strategy.id } of #{ @type } is not valid" % }
22+ {% end % }
23+ end
24+ {% end % }
2325 end
2426 end
2527
You can’t perform that action at this time.
0 commit comments