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.
33 34 35 36 37 38 39 40 |
# File 'lib/hanami/assets/asset.rb', line 33 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.
25 26 27 |
# File 'lib/hanami/assets/asset.rb', line 25 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.
29 30 31 |
# File 'lib/hanami/assets/asset.rb', line 29 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.
21 22 23 |
# File 'lib/hanami/assets/asset.rb', line 21 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/hanami/assets/asset.rb', line 50 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.
44 45 46 |
# File 'lib/hanami/assets/asset.rb', line 44 def precompile? original && config end |