timriley on more-flexible-component-dir-config
timriley on add-glossary
Moar glossary (compare)
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
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