Class: AssetHostSelection::AssetProvider
- Inherits:
-
Object
- Object
- AssetHostSelection::AssetProvider
- Defined in:
- lib/asset_host_selection.rb
Instance Attribute Summary collapse
-
#cdn ⇒ Object
Returns the value of attribute cdn.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
Class Method Summary collapse
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #host ⇒ Object
-
#initialize(options = {}) ⇒ AssetProvider
constructor
A new instance of AssetProvider.
Constructor Details
#initialize(options = {}) ⇒ AssetProvider
Returns a new instance of AssetProvider.
20 21 22 23 24 25 |
# File 'lib/asset_host_selection.rb', line 20 def initialize( = {}) @domain = .fetch(:domain) @subdomain = .fetch(:subdomain) @enabled = [:enabled] @cdn = [:cdn] end |
Instance Attribute Details
#cdn ⇒ Object
Returns the value of attribute cdn.
5 6 7 |
# File 'lib/asset_host_selection.rb', line 5 def cdn @cdn end |
#enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'lib/asset_host_selection.rb', line 5 def enabled @enabled end |
Class Method Details
.build_all(attributes = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 |
Instance Method Details
#enabled? ⇒ Boolean
31 32 33 34 |
# File 'lib/asset_host_selection.rb', line 31 def enabled? return false if @cdn && cdn_disabled? @enabled != false end |
#host ⇒ Object
27 28 29 |
# File 'lib/asset_host_selection.rb', line 27 def host @host ||= [ @subdomain, @domain ].join(".") end |