Skip to content

Commit

Permalink
Prefer require_relative for internal requires
Browse files Browse the repository at this point in the history
`require_relative` is preferred over `require` for files within the same
project because it uses paths relative to the current file, making code
more portable and less dependent on the load path.

This change updates internal requires to use `require_relative` for
consistency, performance, and improved portability.

Ref:
- activeadmin/arbre#622
  • Loading branch information
tagliala committed Sep 19, 2024
1 parent 9cabeb6 commit e20fa1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/inherited_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# This is here because responders don't require it.
require 'rails/engine'
require 'responders'
require 'inherited_resources/engine'
require 'inherited_resources/blank_slate'
require 'inherited_resources/responder'

require_relative 'inherited_resources/engine'
require_relative 'inherited_resources/blank_slate'
require_relative 'inherited_resources/responder'

module InheritedResources
ACTIONS = [ :index, :show, :new, :edit, :create, :update, :destroy ] unless self.const_defined?(:ACTIONS)
Expand Down
2 changes: 1 addition & 1 deletion lib/inherited_resources/base_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Whenever base is required load the dumb responder since it's used inside actions.
require 'inherited_resources/blank_slate'
require_relative 'blank_slate'

module InheritedResources
# Base helpers for InheritedResource work. Some methods here can be overwritten
Expand Down

0 comments on commit e20fa1a

Please sign in to comment.