Sha256: 9d6f227df8d7f6ecbefb38b1e76608f21bd03a1dc62e81e8a63fab81b2055d3c

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Odania
	module Config
		class Internal
			attr_accessor :partials, :layouts

			def initialize
				reset
			end

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

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

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

			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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
odania-0.0.18 lib/odania/config/internal.rb