Class Mack::Assets::Manager
In: lib/mack/assets/assets_mgr.rb
Parent: Object

Like the name suggests, this object will manage assets (i.e. scripts and stylesheets) used in a mack application. Developer will be able to use the manager to create assets groups, and refer them later in the erb file. <br> There‘s a convenient method available, called assets_mgr. Application should use that method to create new bundle, and to access defined bundles. <br> Example:

  # This will create new bundle called foo
  assets_mgr.foo do |a|
    a.add_js "foo"
    a.add_css "bar"
  end

Note that nested group is not supported.

Methods

Included Modules

Singleton

Public Instance methods

[Source]

     # File lib/mack/assets/assets_mgr.rb, line 139
139:       def assets(asset_type, group)
140:         return nil if !@bundles.has_key?(group.to_s)
141:         return @bundles[group.to_s].assets(asset_type)
142:       end

return all groups defined for both javascript and stylesheets

[Source]

     # File lib/mack/assets/assets_mgr.rb, line 114
114:       def groups
115:         @bundles.keys
116:       end

Return all groups defined by specified asset type

Params:

  type -- asset type (can be either :javascript or :stylesheet)

[Source]

     # File lib/mack/assets/assets_mgr.rb, line 123
123:       def groups_by_asset_type(type)
124:         arr = []
125:         groups.each do |group|
126:           arr << group if !@bundles[group.to_s].assets(type.to_sym).empty?
127:         end
128:         return arr
129:       end

[Source]

     # File lib/mack/assets/assets_mgr.rb, line 131
131:       def has_group?(group, asset_type = nil)
132:         if asset_type
133:           return groups_by_asset_type(asset_type).include?(group.to_s)
134:         else
135:           return groups.include?(group)
136:         end
137:       end

[Source]

     # File lib/mack/assets/assets_mgr.rb, line 144
144:       def javascripts(group)
145:         return assets(:javascripts, group)
146:       end

Clear the defined assets

[Source]

    # File lib/mack/assets/assets_mgr.rb, line 94
94:       def reset!
95:         @bundles.clear
96:       end

[Source]

     # File lib/mack/assets/assets_mgr.rb, line 148
148:       def stylesheets(group)
149:         return assets(:stylesheets, group)
150:       end

[Validate]