Skip to content

Instantly share code, notes, and snippets.

@blelump

blelump/a.rb Secret

Created May 25, 2016 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blelump/0f00ae00e4d5aba285a3b3fed267f69e to your computer and use it in GitHub Desktop.
Save blelump/0f00ae00e4d5aba285a3b3fed267f69e to your computer and use it in GitHub Desktop.
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