GustavoCaso on fix-vulnerability
timriley on cherry-pick-concurrent-requires
timriley on master
Cherry-pick “concurrent/map” re… Merge pull request #406 from dr… (compare)
# schema: required(:name).filled optional(:age).maybe # spec: expect(schema).to have_required_key(:name).filled expect(schema).to have_optional_key(:age).maybe
Question - I’m looking at using dry-rb to build a re-usable gem that allows the consuming application to define & configure the persistenance layer, and other infrastructure related dependencies. I’ve got this more or less working when I explictly ask the container to resolve the dependency just before I need the service.
class SaveMyEntity def call(entity) my_repo = MyContainer[‘persistence.my_repo’] my_repo.save(entity) end end
I’m wondering if I can also use either dry-auto_inject and/or dry-system to also do this? However, from what I can see, using the auto loading and the auto injector work differently.
Import = Dry::AutoInject(MyContainer) class SaveMyEntity include Import[‘persistence.my_repo’] # throws Dry::System::ComponentLoadError: could not load component end
Import = Dry::AutoInject(Container) # works Import = Container.injector # throws Dry::System::ComponentLoadError: could not load component
I’m currently calling one of those 2 lines inside a module pretty much when the gem is initially loaded. The first line seems to work, but the 2nd throws the error when I use the Import in a subsequent ruby file. Should I be deferrring these until after the consuming application has a chance to register it’s own dependencies?
Basically, just trying to figure out the correct pattern to use moving forward. I’m not sure, if I should be bothering with dry-system in my case or just leverage dry-container and possibly dry-auto_inject.
# Require the container require_relative "main/container" # Load files with manually registered dependencies Main::Container.require "component/container/persistence" # Finalize the container, which does auto-registration if you've configured it Main::Container.finalize!
Hi guys, I have some trouble using dry-validation. I am trying to ensure that some ids I receive from my API are actually valid records in my database. In my form I have this :
property sender_ids required(:sender_ids) do filled? & array? end rule(valid_senders: [:sender_ids]) do |sender_ids| Contact.exists?(id: value(:sender_ids)) end
But it raises the following error :
POST /letters with valid data returns the new letter Failure/Error: rule(valid_senders: [:sender_ids]) do |sender_ids| Contact.exists?(id: value(:sender_ids)) end NoMethodError: undefined method `with' for false:FalseClass # ./.gems/gems/dry-validation-0.10.4/lib/dry/validation/schema/value.rb:96:in `rule' # ./app/forms/letter/create_form.rb:31:in `block in <class:CreateForm>’
Do you have any idea ?