Last active
February 11, 2016 00:34
-
-
Save nicholasjhenry/e097260f9e4cb6440065 to your computer and use it in GitHub Desktop.
EBA Cheatsheet
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
| # Responsibilites: | |
| # - specific, focused task | |
| # - presenting data to the user | |
| class Worker1 | |
| end | |
| class Worker2 | |
| end | |
| class Builder | |
| attr_reader :binder, :worker_1, :worker_2 | |
| def build | |
| @binder = Binder.new(self) | |
| @worker_1 = Worker1.new | |
| @worker_2 = Worker2.new | |
| end | |
| end | |
| class Binder | |
| def initialize | |
| @builder = builder | |
| end | |
| def bind(context) | |
| @builder.worker_1.notification += @builder.worker_2.handler | |
| @builder.worker_2.notification += context.handler | |
| end | |
| end | |
| # Responsibilities: | |
| # - coordinate the actions of one or more workers | |
| # - retrieve data for workers | |
| class Coordinator | |
| def call(params, context = NullContext.new) | |
| builder = Builder.build | |
| builder.binder.bind(context) | |
| builder.worker_1.call(params) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment