Skip to content

Commit

Permalink
Correctly remove the buildin rails adapter
Browse files Browse the repository at this point in the history
`defined?` for a string literal is always truthy, same as for symbols.
`defined?(ActiveJob::QueueAdapters::SneakersAdapter)` would work as an alternative.

```rb
module ActiveJob
  module QueueAdapters
    # Adapter removed from rails
  end
end

module ActiveJob
  module QueueAdapters
    remove_const(:SneakersAdapter) if defined?("::#{name}::SneakersAdapter")
  end
end
```

test.rb:10:in `remove_const': constant ActiveJob::QueueAdapters::SneakersAdapter not defined (NameError)
  • Loading branch information
Earlopain committed Nov 8, 2024
1 parent 185b51c commit 9a37d90
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_job/queue_adapters/sneakers_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module ActiveJob
module QueueAdapters
# Explicitly remove the implementation existing in older Rails versions'.
remove_const(:SneakersAdapter) if defined?("::#{name}::SneakersAdapter")
remove_const(:SneakersAdapter) if const_defined?(:SneakersAdapter)

# = Sneakers adapter for Active Job
#
Expand Down

0 comments on commit 9a37d90

Please sign in to comment.