class CabezaDeTermo::Assets::Bundle

A list of assets and other bundles to be collected by an assets_collector. A bundle can include a reference to an asset, such as ‘jquery.js’, or require a reference to another bundle.

The bundles are defined in the Library.definition, example:

CabezaDeTermo::Assets::Library.definition do
        bundle :'bootstrap-js' do
                require :jquery
                include 'asset_2.js'
        end
end

Public Class Methods

new() click to toggle source

Initialize the instance

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 21
def initialize
        @references = []
end

Public Instance Methods

collect_assets_with(assets_collector) click to toggle source

Add all the referenced assets to the assets_collector. Add both the assets included in this bundle and the assets included in another bundles required by this bundle.

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 45
def collect_assets_with(assets_collector)
        @references.each do |asset|
                asset.collect_assets_with assets_collector
        end
end
include(asset) click to toggle source

Include a reference to the asset. The asset can be any string, such as ‘/vendor/jquery.js’.

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 32
def include(asset)
        @references << new_asset_reference_on(asset)
end
new_asset_reference_on(asset) click to toggle source

Create a new AssetReference on the asset

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 52
def new_asset_reference_on(asset)
        AssetReference.on asset
end
new_assets_bundle_reference_on(bundle_name) click to toggle source

Create a new BundleReference on the bundle_name

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 57
def new_assets_bundle_reference_on(bundle_name)
        BundleReference.on bundle_name
end
references() click to toggle source

Answer the list of references defined for this bundle. References may be any combination of AssetReference and BundleReference.

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 27
def references
        @references
end
require(bundle_name) click to toggle source

Require a reference to another bundle named bundle_name. By requiring another bundle, the assets_collector will collect all the assets in the another bundle.

# File lib/cabeza-de-termo/assets/bundles/bundle.rb, line 39
def require(bundle_name)
        @references << new_assets_bundle_reference_on(bundle_name)
end