Class: Hanami::Assets::BaseUrl Private
- Inherits:
-
Object
- Object
- Hanami::Assets::BaseUrl
- Defined in:
- lib/hanami/assets/base_url.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.
Base URL
Instance Method Summary collapse
-
#crossorigin?(source) ⇒ Boolean
private
Check if the source is a cross origin.
-
#initialize(url, prefix = nil) ⇒ BaseUrl
constructor
private
Initialize a base URL.
-
#join(other) ⇒ String
private
Join the base URL with the given paths.
- #to_s ⇒ Object private
Constructor Details
#initialize(url, prefix = nil) ⇒ BaseUrl
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.
Initialize a base URL
24 25 26 27 |
# File 'lib/hanami/assets/base_url.rb', line 24 def initialize(url, prefix = nil) @url = URI(url + prefix.to_s).to_s freeze end |
Instance Method Details
#crossorigin?(source) ⇒ 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.
Check if the source is a cross origin
53 54 55 56 57 58 |
# File 'lib/hanami/assets/base_url.rb', line 53 def crossorigin?(source) # TODO: review if this is the right way to check for cross origin return true if @url.empty? !source.start_with?(@url) end |
#join(other) ⇒ String
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.
Join the base URL with the given paths
36 37 38 |
# File 'lib/hanami/assets/base_url.rb', line 36 def join(other) (url + other).to_s end |
#to_s ⇒ Object
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.
42 43 44 |
# File 'lib/hanami/assets/base_url.rb', line 42 def to_s @url end |