class HasFilepickerImage::UrlBuilder

Public Class Methods

new(options) click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 3
def initialize(options)
  @url        = options[:url]
  @options    = ApiOptions.new(options[:styles], *options[:args])
  @asset_host = Rails.application.config.has_filepicker_image.asset_host
end

Public Instance Methods

url() click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 9
def url
  replace_asset_host(@url) + query_component if @url.present?
end

Private Instance Methods

query_component() click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 25
def query_component
  component =  @options.with_conversion_options? ? '/convert' : ''
  component + '?' + @options.sort.map { |k,v| "#{k}=#{v}" }.join('&')
end
replace_asset_host(url) click to toggle source
# File lib/has_filepicker_image/url_builder.rb, line 15
def replace_asset_host(url)
  if @asset_host
    uri = URI(url)
    uri.host = @asset_host
    uri.to_s
  else
    url
  end
end