Class: Odania::Config::PageBase

Inherits:
Object
  • Object
show all
Defined in:
lib/odania/config/page_base.rb

Direct Known Subclasses

Layout, SubDomain

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePageBase

Returns a new instance of PageBase.



6
7
8
# File 'lib/odania/config/page_base.rb', line 6

def initialize
	reset
end

Instance Attribute Details

#assetsObject

Returns the value of attribute assets.



4
5
6
# File 'lib/odania/config/page_base.rb', line 4

def assets
  @assets
end

Instance Method Details

#[](type) ⇒ Object



31
32
33
# File 'lib/odania/config/page_base.rb', line 31

def [](type)
	self.assets
end

#add(data, group_name = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/odania/config/page_base.rb', line 10

def add(data, group_name=nil)
	duplicates = Hash.new { |hash, key| hash[key] = [] }
	unless data['assets'].nil?
		data['assets'].each_pair do |name, asset_data|
			duplicates[:assets] << name if self.assets.key? name
			self.assets[name].load(asset_data, group_name)
		end
	end
	duplicates
end

#dumpObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/odania/config/page_base.rb', line 35

def dump
	asset_data = {}
	assets.each_pair do |web_url, page|
		asset_data[web_url] = page.dump
	end

	{
		'assets' => asset_data
	}
end

#load(data, group_name) ⇒ Object



21
22
23
# File 'lib/odania/config/page_base.rb', line 21

def load(data, group_name)
	self.add(data, group_name)
end

#resetObject



25
26
27
28
29
# File 'lib/odania/config/page_base.rb', line 25

def reset
	self.assets = Hash.new { |hash, key| hash[key] = Page.new }

	@plugins = {:assets => Hash.new { |hash, key| hash[key] = [] }}
end