Skip to content

Instantly share code, notes, and snippets.

@stergiom stergiom/output.sh Secret
Last active May 23, 2017

Embed
What would you like to do?
>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'
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
You can’t perform that action at this time.