-
-
Save stergiom/f4d79fa01488401dcf5e3334e002e869 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
>jruby tmp/script.rb | |
=> Greetings & Salutaitons! | |
>pry | |
[1] pry(main)> require "/tmp/script.rb" | |
=> true | |
[2] pry(main)> Desperado.new | |
Greetings & Salutaitons! | |
=> #<Desperado:0x1aeff8ca @wingman=#<Wingman:0xf10d055>> | |
>jrubyc script.rb | |
>pry | |
[1] pry(main)> require "/tmp/script.class" | |
=> true | |
[2] pry(main)> Desperado.new | |
ArgumentError: unknown keyword: | |
from /Users/usr/.rvm/gems/jruby-9.1.9.0/gems/dry-auto_inject-0.4.2/lib/dry/auto_inject/strategies/kwargs.rb:22:in `initialize' |
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
require "dry-container" | |
require "dry-auto_inject" | |
class Wingman | |
def greet | |
puts "Greetings & Salutaitons!" | |
end | |
end | |
class SomeContainer | |
extend Dry::Container::Mixin | |
end | |
SomeContainer.register(:wingman, Wingman.new) | |
Inject = Dry::AutoInject(SomeContainer) | |
class Desperado | |
include Inject[:wingman] | |
def initialize(*, **, &b) | |
super | |
prod_wingman | |
end | |
def prod_wingman | |
wingman.greet | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment