Class: Hanami::Assets::Asset Private
- Inherits:
-
Object
- Object
- Hanami::Assets::Asset
- Defined in:
- lib/hanami/assets/asset.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Requested asset
Constant Summary collapse
- PUBLIC_DIRECTORY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Hanami.public_directory.join('**', '*').to_s.freeze
- URL_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'/'.freeze
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
- #original ⇒ Object readonly private
- #path ⇒ Object readonly private
Instance Method Summary collapse
- #exist? ⇒ Boolean private
-
#initialize(sources, path) ⇒ Asset
constructor
private
A new instance of Asset.
- #precompile? ⇒ Boolean private
Constructor Details
#initialize(sources, path) ⇒ Asset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Asset.
32 33 34 35 36 37 38 39 |
# File 'lib/hanami/assets/asset.rb', line 32 def initialize(sources, path) @path = path @prefix, @config = sources.find { |p, _| path.start_with?(p) } if @prefix && @config @original = @config.sources.find(@path.sub(@prefix, '')) end end |
Instance Attribute Details
#config ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/hanami/assets/asset.rb', line 24 def config @config end |
#original ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/hanami/assets/asset.rb', line 28 def original @original end |
#path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/hanami/assets/asset.rb', line 20 def path @path end |
Instance Method Details
#exist? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hanami/assets/asset.rb', line 49 def exist? return true unless original.nil? file_path = path.tr(URL_SEPARATOR, ::File::SEPARATOR) destination = find_asset do |a| a.end_with?(file_path) end !destination.nil? end |
#precompile? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/hanami/assets/asset.rb', line 43 def precompile? original && config end |