Last active
December 19, 2015 08:39
-
-
Save nicholasjhenry/5927144 to your computer and use it in GitHub Desktop.
Thoughts from Internals and Peers discussion
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
| # Create a nice DSL around the service factories. The DSL becomes a list of commands the Applicaton supports. | |
| module MyApp | |
| module_function | |
| def ship_package(package_id) | |
| service = ShipIssueFactory.build(package_id) | |
| service.call | |
| end | |
| end | |
| class PackageShipmentsController | |
| def create | |
| MyApp.ship_package(params[:package_id] | |
| end | |
| end | |
| # alternatively | |
| class PackageShipmentsController | |
| include MyApp | |
| def create | |
| ship_package(params[:package_id] | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have been undecided whether to pass in package_id or a package object, but migrating it to a background job is trivial when using a package_id: