Class: Mack::Assets::Bundle
Overview
:nodoc:
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#add_css(files) ⇒ Object
(also: #stylesheet)
Add stylesheet file(s) to the group/bundle.
-
#add_js(files) ⇒ Object
(also: #javascript)
Add javascript file(s) to the group/bundle.
- #assets(asset_type) ⇒ Object
-
#initialize(bundle_name) ⇒ Bundle
constructor
A new instance of Bundle.
- #remove_css(files) ⇒ Object
- #remove_js(files) ⇒ Object
- #reset!(type = :all) ⇒ Object
Constructor Details
#initialize(bundle_name) ⇒ Bundle
Returns a new instance of Bundle.
7 8 9 10 |
# File 'lib/mack/assets/assets_mgr.rb', line 7 def initialize(bundle_name) self.name = bundle_name self.data = {:javascripts => [], :stylesheets => []} end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/mack/assets/assets_mgr.rb', line 4 def data @data end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/mack/assets/assets_mgr.rb', line 5 def name @name end |
Instance Method Details
#add_css(files) ⇒ Object Also known as: stylesheet
Add stylesheet file(s) to the group/bundle
32 33 34 |
# File 'lib/mack/assets/assets_mgr.rb', line 32 def add_css(files) return add_data(files, :stylesheets, '.css') end |
#add_js(files) ⇒ Object Also known as: javascript
Add javascript file(s) to the group/bundle
19 20 21 |
# File 'lib/mack/assets/assets_mgr.rb', line 19 def add_js(files) return add_data(files, :javascripts, '.js') end |
#assets(asset_type) ⇒ Object
12 13 14 |
# File 'lib/mack/assets/assets_mgr.rb', line 12 def assets(asset_type) self.data[asset_type] end |
#remove_css(files) ⇒ Object
37 38 39 40 |
# File 'lib/mack/assets/assets_mgr.rb', line 37 def remove_css(files) files = [files].flatten self.data[:stylesheets] -= files end |
#remove_js(files) ⇒ Object
24 25 26 27 |
# File 'lib/mack/assets/assets_mgr.rb', line 24 def remove_js(files) files = [files].flatten self.data[:javascripts] -= files end |
#reset!(type = :all) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/mack/assets/assets_mgr.rb', line 42 def reset!(type = :all) if type == :all self.data.keys.each do |key| self.data[key].clear end else self.data[type].clear if self.data[type] end end |