Class: Odania::Config::Internal

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInternal

Returns a new instance of Internal.



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

def initialize
	reset
end

Instance Attribute Details

#layoutsObject

Returns the value of attribute layouts.



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

def layouts
  @layouts
end

#partialsObject

Returns the value of attribute partials.



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

def partials
  @partials
end

Instance Method Details

#assetsObject



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

def assets
	result = {}
	self.layouts.each_pair do |_name, layout|
		layout.assets.each_pair do |key, val|
			result[key] = val
		end
	end
	result
end

#dumpObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/odania/config/internal.rb', line 35

def dump
	partial_data = {}
	partials.each_pair do |web_url, page|
		partial_data[web_url] = page.dump
	end

	layout_data = {}
	layouts.each_pair do |web_url, page|
		layout_data[web_url] = page.dump
	end

	{
		'layouts' => layout_data,
		'partials' => partial_data
	}
end

#load(data, group_name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/odania/config/internal.rb', line 20

def load(data, group_name)
	reset
	unless data['partials'].nil?
		data['partials'].each_pair do |name, partial_data|
			self.partials[name].load(partial_data)
		end
	end

	unless data['layouts'].nil?
		data['layouts'].each_pair do |name, layout_data|
			self.layouts[name].load(layout_data, group_name)
		end
	end
end

#resetObject



52
53
54
55
# File 'lib/odania/config/internal.rb', line 52

def reset
	self.layouts = Hash.new { |hash, key| hash[key] = Layout.new }
	self.partials = Hash.new { |hash, key| hash[key] = Page.new }
end