Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Last active February 11, 2016 00:34
Show Gist options
  • Select an option

  • Save nicholasjhenry/e097260f9e4cb6440065 to your computer and use it in GitHub Desktop.

Select an option

Save nicholasjhenry/e097260f9e4cb6440065 to your computer and use it in GitHub Desktop.
EBA Cheatsheet
# 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