These are chat archives for dry-rb/chat
Next-gen ruby libs! » github.com/dry-rb » website: https://dry-rb.org » forum: https://discourse.dry-rb.org
orElsefor java's optional? or is the monadic type a point of no return?
I have a use case where I have a DB adapter (which has itself an injected DB client ). I'd like to do something like this.
class MyCustomObjectXRepo include Import['persistence.adapter', collection_name: 'object_x'] def pending adapter.find(status: 'pending', created_by: current_user) end
I'd like to be able to inject a new instance of the adapter but initialized for the specific collection_name. Is there a clean way to do with with dry-autoinject / dry-containers?
At the moment, I'm just injecting in a builder and constructing the adapter lazily instead, but doesn't feel clean to me
class MyCustomObjectXRepo include Import['persistence.adapter_builder'] def adapter @adapter ||= adapter_builder.create(collection_name: 'object_x') end
dry-rom:) you probably meant
rom-mongowhich as mongodb adapter for rom, but it's not production ready yet