-
-
Save blelump/0f00ae00e4d5aba285a3b3fed267f69e to your computer and use it in GitHub Desktop.
This file contains 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
my_container = Dry::Container.new | |
my_container.register(:'one.data_store', -> { A.new }) | |
my_container.register(:'two.data_store', -> { A.new }) | |
Import = Dry::AutoInject(my_container) | |
class OP | |
attr_reader :context | |
def initialize(**args) | |
@context = args.fetch(:context) | |
end | |
end | |
class B < OP | |
include Import.kwargs[blah: 'one.data_store', bleh: 'two.data_store'] | |
def initialize(**args) | |
super | |
end | |
def call | |
p context.x | |
bleh.call | |
end | |
end | |
B.new(context: OpenStruct.new(x: :y)).call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment