Class: Mack::Assets::Helpers
- Inherits:
-
Object
- Object
- Mack::Assets::Helpers
- Includes:
- Singleton
- Defined in:
- lib/mack/assets/asset_helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#asset_hosts(source = '') ⇒ Object
Return the asset hosts for this application.
-
#asset_hosts=(host) ⇒ Object
Set the asset hosts for this app.
-
#max_distribution ⇒ Object
Return the max number of asset hosts distribution.
-
#reset! ⇒ Object
Clear previously set configuration for asset hosts.
Instance Method Details
#asset_hosts(source = '') ⇒ Object
Return the asset hosts for this application.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mack/assets/asset_helpers.rb', line 29 def asset_hosts(source = '') ret_val = '' # if no explicit asset_host setting, then use the one defined in configatron (if exists) host = @hosts || (configatron.mack.assets.hosts.nil? ? '' : configatron.mack.assets.hosts) if host.kind_of?(Proc) ret_val = host.call(source) else ret_val = sprintf(host, rand(max_distribution)) end return ret_val end |
#asset_hosts=(host) ⇒ Object
Set the asset hosts for this app. It supports the following format:
-
plain string: the string literal will be considered as the asset hosts (e.g. ‘assets.foo.com’)
-
formatted string: to support asset host distribution (e.g. ‘asset%d.foo.com’)
-
a proc object: to support custom asset hosts generation (e.g. Proc.new { |source| ‘assets.foo.com’ }
The max number of distribution can be set from configatron.mack.assets.max_distribution. The default value is 4
15 16 17 |
# File 'lib/mack/assets/asset_helpers.rb', line 15 def asset_hosts=(host) @hosts = host end |
#max_distribution ⇒ Object
Return the max number of asset hosts distribution
22 23 24 |
# File 'lib/mack/assets/asset_helpers.rb', line 22 def max_distribution return configatron.mack.assets.max_distribution end |
#reset! ⇒ Object
Clear previously set configuration for asset hosts
46 47 48 |
# File 'lib/mack/assets/asset_helpers.rb', line 46 def reset! @hosts = nil end |