Skip to content

Commit

Permalink
Remove upfront extension requires
Browse files Browse the repository at this point in the history
This commit addresses an issue where we were requiring all extension
files upfront, which could raise errors if the required gems were not
present in the user's environment. To resolve this, we've removed the
automatic requires for ActiveRecord and ROM extensions from
lib/dry/operation.rb.

Instead, we've updated the documentation in both ActiveRecord and ROM
extension files to include the necessary require statement in the example
code. To ensure our tests continue to pass with these changes, we've also added
the requires to the spec_helper file.

See report: 92cdde9#commitcomment-146824502
  • Loading branch information
waiting-for-dev committed Sep 17, 2024
1 parent 92cdde9 commit 964dc88
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/dry/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require "zeitwerk"
require "dry/monads"
require "dry/operation/errors"
require "dry/operation/extensions/active_record"
require "dry/operation/extensions/rom"

module Dry
# DSL for chaining operations that can fail
Expand Down
2 changes: 2 additions & 0 deletions lib/dry/operation/extensions/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module Extensions
# back and, as usual, the rest of the flow will be skipped.
#
# ```ruby
# require "dry/operation/extensions/active_record"
#
# class MyOperation < Dry::Operation
# include Dry::Operation::Extensions::ActiveRecord
#
Expand Down
2 changes: 2 additions & 0 deletions lib/dry/operation/extensions/rom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Extensions
# container via a `#rom` method.
#
# ```ruby
# require "dry/operation/extensions/rom"
#
# class MyOperation < Dry::Operation
# include Dry::Operation::Extensions::ROM
#
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Bundler.require :tools

require "dry/operation"
require "dry/operation/extensions/active_record"
require "dry/operation/extensions/rom"

SPEC_ROOT = Pathname(__dir__).realpath.freeze

Expand Down

0 comments on commit 964dc88

Please sign in to comment.