Skip to content

Commit

Permalink
Merge pull request #382 from rails/schneems/reslove!
Browse files Browse the repository at this point in the history
Use existing resolve! api for find_asset!
  • Loading branch information
schneems authored Sep 13, 2016
2 parents d590c1c + e906900 commit 99444c0
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/sprockets/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ def [](*args)
#
# If the asset is not found an error will be raised.
def find_asset!(*args)
asset = find_asset(*args)
if asset
return asset
else
raise_on_unknown_asset(*args)
uri, _ = resolve!(*args)
if uri
load(uri)
end
end

Expand All @@ -119,13 +117,5 @@ def compress_from_root(uri)
def expand_from_root(uri)
URITar.new(uri, self).expand
end

private
def raise_on_unknown_asset(*args)
asset_name = args.shift
msg = String.new("Could not load asset #{ asset_name.inspect }")
msg << "with options #{ args.inspect }" unless args.empty?
raise Sprockets::NotFound, msg
end
end
end

0 comments on commit 99444c0

Please sign in to comment.