Class: Mack::Assets::Bundle

Inherits:
Object show all
Defined in:
lib/mack/assets/assets_mgr.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/mack/assets/assets_mgr.rb', line 4

def data
  @data
end

#nameObject

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