Class: Pinion::BundleType
- Inherits:
-
Object
- Object
- Pinion::BundleType
- Defined in:
- lib/pinion/bundle_type.rb
Overview
A ‘BundleType` is a description of how to bundle together multiple assets of the same type. New types of `Bundle`s may be created with `BundleType.create`. A particular bundle type is simply a Proc that knows how to bundle together a set of assets. For convenience, there is a built-in `BundleType` type already defined, `:concatenate_and_uglify_js`.
Constant Summary collapse
- @@bundle_types =
{}
Class Method Summary collapse
-
.[](name) ⇒ Object
Retrieve a ‘BundleType` by name.
-
.create(name, &block) ⇒ Object
Create a new bundle definition.
Instance Method Summary collapse
-
#initialize(definition_proc) ⇒ BundleType
constructor
A new instance of BundleType.
-
#process(assets) ⇒ Object
Process an array of ‘Asset`s to produce the bundled result.
Constructor Details
#initialize(definition_proc) ⇒ BundleType
Returns a new instance of BundleType.
9 10 11 |
# File 'lib/pinion/bundle_type.rb', line 9 def initialize(definition_proc) @definition_proc = definition_proc end |
Class Method Details
.[](name) ⇒ Object
Retrieve a ‘BundleType` by name.
25 |
# File 'lib/pinion/bundle_type.rb', line 25 def self.[](name) @@bundle_types[name] end |
.create(name, &block) ⇒ Object
Create a new bundle definition. The block will be called with argument ‘assets`, the array of `Asset`s.
-
assets: an array of ‘Asset`s
20 21 22 |
# File 'lib/pinion/bundle_type.rb', line 20 def self.create(name, &block) @@bundle_types[name] = BundleType.new(block) end |
Instance Method Details
#process(assets) ⇒ Object
Process an array of ‘Asset`s to produce the bundled result.
14 15 16 |
# File 'lib/pinion/bundle_type.rb', line 14 def process(assets) @definition_proc.call(assets) end |