Skip to content

Commit

Permalink
instead of respond_to? using attr_accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
honeyankit authored and jurre committed May 23, 2024
1 parent d07121d commit aecaa41
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions bundler/helpers/v2/monkey_patches/lazy_specification_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,16 @@
# Check if the gem is a default gem
# Ensure loaded_from is not nil and check if the gem is located in the default specifications directory
module LazySpecificationDefaultGemPatch
attr_accessor :loaded_from unless instance_methods.include?(:loaded_from)

def default_gem?
# Check if `loaded_from` responds and is not nil, and verify its directory
if respond_to?(:loaded_from) && loaded_from
if loaded_from
File.dirname(loaded_from) == Gem.default_specifications_dir
else
false
end
end

# Ensuring loaded_from is defined in the LazySpecification
def loaded_from
@loaded_from
end

def loaded_from=(path)
@loaded_from = path
end
end

# Prepend the module to Bundler::LazySpecification to add the default_gem? method
Expand Down

0 comments on commit aecaa41

Please sign in to comment.