class AssetHostSelection::AssetProvider
Attributes
cdn[RW]
enabled[RW]
Public Class Methods
build_all(attributes = {})
click to toggle source
# File lib/asset_host_selection.rb, line 7 def self.build_all(attributes = {}) providers = {} settings_to_provider = {} settings_to_provider.compare_by_identity attributes.each do |key, settings| providers[key.to_sym] = settings_to_provider.fetch(settings) do settings_to_provider[settings] = new(settings) end end providers end
new(options = {})
click to toggle source
# File lib/asset_host_selection.rb, line 20 def initialize(options = {}) @domain = options.fetch(:domain) @subdomain = options.fetch(:subdomain) @enabled = options[:enabled] @cdn = options[:cdn] end
Public Instance Methods
enabled?()
click to toggle source
# File lib/asset_host_selection.rb, line 31 def enabled? return false if @cdn && cdn_disabled? @enabled != false end
host()
click to toggle source
# File lib/asset_host_selection.rb, line 27 def host @host ||= [ @subdomain, @domain ].join(".") end
Protected Instance Methods
cdn_disabled?()
click to toggle source
# File lib/asset_host_selection.rb, line 38 def cdn_disabled? ENV['DISABLE_CDN'] =~ /yes|true/ end