Skip to content

Commit 17264b3

Browse files
author
Rafael Mendonça França
committed
Refactoring the check_dependencies method to call only inside sprockets
context
1 parent 6077dd5 commit 17264b3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/sprockets/rails/helper.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,10 @@ def self.extended(obj)
4444
end
4545
end
4646

47-
def check_dependencies!(dep)
48-
return unless @_dependency_assets
49-
return if @_dependency_assets.detect { |asset| asset.include?(dep) }
50-
raise DependencyError.new(self.pathname, dep)
51-
end
52-
5347
def compute_asset_path(path, options = {})
54-
check_dependencies!(path)
48+
# Check if we are inside Sprockets context before calling check_dependencies!.
49+
check_dependencies!(path) if defined?(_dependency_assets)
50+
5551
if digest_path = asset_digest_path(path)
5652
path = digest_path if digest_assets
5753
path += "?body=1" if options[:debug]
@@ -140,6 +136,14 @@ def stylesheet_link_tag(*sources)
140136
end
141137

142138
protected
139+
140+
# Checks if the asset is included in the dependencies list.
141+
def check_dependencies!(dep)
142+
if !_dependency_assets.detect { |asset| asset.include?(dep) }
143+
raise DependencyError.new(self.pathname, dep)
144+
end
145+
end
146+
143147
# Enable split asset debugging. Eventually will be deprecated
144148
# and replaced by source maps in Sprockets 3.x.
145149
def request_debug_assets?

0 commit comments

Comments
 (0)