These are chat archives for dry-rb/chat
dry-auto_injector just add
Dry::AutoInject works Finished in 0.00313 seconds (files took 0.20784 seconds to load) 1 example, 0 failures
byebugin dry-auto_inject :joy:
NoMethodError: undefined method `synchronize' for nil:NilClass # /home/vagrant/.gem/ruby/2.2.0/gems/dry-configurable-0.1.1/lib/dry/configurable.rb:42:in `config’
MyClass.new(nil, ‘foo’)and first arg will be injected
class MyClass include Dry::AutoInject[:user_repository, :current_user] def initialize(repository, user, user_attributes) # ... end end # args length is the same as (required args - injected args) (resolve) MyClass.new(name: 'Jack') # args length is greater than as (required args - injected args) (don't resolve or arg error) MyClass.new(user_repo, current_user, name: 'Jill')
my_modelas well as a method
my_modelyou also get
MyModel, which looks like you aren't even using dependency injection (if that makes sense).
*operator (classical fn composition) and we could add a logo and maybe start promoting things here and there
MyModel.find, with dependency injection it would be
my_model.find. My idea was to define a method, not class, called
MyModelso it looked visually the same with DI as without.
MyModel.findor inject the "repository" in the constructor IMO, would get confusing if it looked like a hard dependency too