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
@timriley, if I test by running an
app.rb from the project root (ie, the dir containing
domain), which looks like this:
require_relative 'system/container' p Application.keys puts Application.config.root.realpath
I get the error:
require_component': could not resolve require file for bot_dialogue (Dry::System::FileNotFoundError)
bot_dialogue.rb is the alphabetically first file in the
domain directory, so this is some progress. It looks like this:
require 'import' class BotDialogue #stuff end
It errors before it gets to the line
puts Application.config.root.realpath in
app.rb so I can’t answer your other question.
root application.rb domain bot_dialogue.rb bot_reply.rb
config.rootsupposed to be the project root, or something else? And what is
load_paths!supposed to specify?
$LOAD_PATH, relative to the project root
$LOAD_PATHuntil it worked
require 'dry/system/container' class Application < Dry::System::Container configure do |config| config.root = Pathname(File.dirname(__FILE__)).parent config.auto_register = ['domain', 'lib', 'use_cases'] end load_paths!('domain', 'lib', 'use_cases') end Application.finalize!
newis automatically invoked on them. But I want the class itself to be returned, not the class called with
to ground that question a bit, consider the example from the docs:
Let’s say that
logger had been auto-registered. How would you specify the
$stdout when creating it? Or some object may need to configure it with a different output, at runtime. So I want the
Logger class itself, so I can call
Logger.new(<whatever i want>) myself.
Hi ! :)
I try to use
around in Dry-Transaction but I have troubles :s
This is my code:
class Containers::Transaction extend ::Dry::Container::Mixin register(:transaction) do |input, &block| puts "Before" ActiveRecord::Base.transaction do next block.(Failure(input)) end puts "After" end end
class User::Invitation::Send include Dry::Transaction(container: Containers::Transaction) around :transaction tee :model! step :persist! tee :mailer! step :email! . . . end
And this give me
NoMethodError: undefined method `Failure' for Containers::Transaction:Class
Did you mean? fail
from /home/necros/.rvm/gems/ruby-2.3.6/gems/dry-configurable-0.7.0/lib/dry/configurable.rb:177:in `method_missing'
This happen with Success too.
Thanks for your help !
dry-transactionthat might be helpful
Dry::Matcherfor the method call