timriley on v0.24.0
timriley on remove-dry-struct
github-actions[bot] on main
[devtools] sync (compare)
action-hero[bot] on main
Update dry-system.gemspec from … (compare)
flash-gordon on main
Remove dry-struct dependency I… Bump version Update CHANGELOG (compare)
FooAction.new.call(args)
- even if I can override the initialize
method, as they describe, this is not how I want to do it, I want to have a single instance of those classes and just pass data through them.Minimise the number of places I have to look to understand what's going on in an individual piece of code.
...without burying me in a five-hundred-line piece of code with a score or three private methods, like too many Rails controllers I've had to do chainsaw surgery on over the years
FooService.new.do_stuff(params)
?
Any idea how to make this work?
require "dry/container"
module Core
class Container
extend Dry::Container::Mixin
register("transaction") do |input, &block|
result = nil
begin
ActiveRecord::Base.transaction do
result = block.call(Dry::Monads::Success(input))
raise ActiveRecord::Rollback if result.failure?
result
end
rescue ActiveRecord::Rollback
require "pry"; binding.pry
result
end
end
end
end
I'm getting the following error:
Dry::Transaction::InvalidResultError: step +transaction+ must return a Result object
I guess because the ActiveRecord::Rollback
is not being rescued.
dry-validation
... is it possible to export a JSON schema file based on a dry schema? I find the dry/ruby stuff much easier to read but my work still depends on JSON schemas