Skip to content

Instantly share code, notes, and snippets.

@apotonick
Last active November 1, 2016 21:45
Show Gist options
  • Save apotonick/63f449b02bd2b3cdbd446fd66e9df022 to your computer and use it in GitHub Desktop.
Save apotonick/63f449b02bd2b3cdbd446fd66e9df022 to your computer and use it in GitHub Desktop.
Auto_inject for TRB2
my_container = Dry::Container.new
my_container.register(:user_repository, -> { Object })
AutoInject = Dry::AutoInject(my_container)
class Create < Trailblazer::Operation
include AutoInject[:user_repository]
end
Create.(params, {})
==> AutoInject overrides Create::call
def call(params, options, *dependencies)
super(params, options.merge(AUTOINJECT-MAGIC), *dependencies)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment