Created
March 29, 2017 02:02
-
-
Save eduardodeoh/3ef63b21e0a4693d3c113365e3c4bb7d to your computer and use it in GitHub Desktop.
Trailblazer and containers - Method 1 - http://trailblazer.to/gems/operation/2.0/api.html#dependency-injection-autoinject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyOperationChild1 < MyOperationMaster | |
AutoInject = Trailblazer::Operation::AutoInject(MyContainer1) | |
include AutoInject[moldel_1_class: "api.v1.model.1.class"] | |
include AutoInject[moldel_2_class: "api.v1.model.2.class"] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyOperationChild2 < MyOperationMaster | |
AutoInject = Trailblazer::Operation::AutoInject(MyContainer2) | |
include AutoInject[moldel_1_class: "api.v1.model.1.class"] | |
include AutoInject[moldel_2_class: "api.v1.model.2.class"] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyOperationMaster < Trailblazer::Operation | |
step :step_one | |
step :step_two | |
def step_one(options, **) | |
options[:model_1_class].create(value: 1) | |
end | |
def step_two(options, **) | |
options[:model_2_class].create(value: 1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment