Class: Odania::Config::Domain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Domain

Returns a new instance of Domain.



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

def initialize(name)
	self.name = name
	reset
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#redirectsObject

Returns the value of attribute redirects.



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

def redirects
  @redirects
end

#subdomainsObject

Returns the value of attribute subdomains.



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

def subdomains
  @subdomains
end

Instance Method Details

#[](key) ⇒ Object



48
49
50
# File 'lib/odania/config/domain.rb', line 48

def [](key)
	self.subdomains[key]
end

#add(sub_domain_data, group_name = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/odania/config/domain.rb', line 32

def add(sub_domain_data, group_name=nil)
	duplicates = Hash.new { |hash, key| hash[key] = [] }
	unless sub_domain_data.nil?
		sub_domain_data.each_pair do |name, data|
			subdomain_duplicates = self.subdomains[name].add(data, group_name)
			duplicates.deep_merge! subdomain_duplicates
		end
	end

	duplicates
end

#add_subdomain(subdomain_name) ⇒ Object



11
12
13
# File 'lib/odania/config/domain.rb', line 11

def add_subdomain(subdomain_name)
	self.subdomains[subdomain_name]
end

#dumpObject



19
20
21
22
23
24
25
# File 'lib/odania/config/domain.rb', line 19

def dump
	subdomain_data = {}
	subdomains.each_pair do |name, subdomain|
		subdomain_data[name] = subdomain.dump
	end
	subdomain_data
end

#get_redirectsObject



44
45
46
# File 'lib/odania/config/domain.rb', line 44

def get_redirects
	self.subdomains['_general'].get_redirects
end

#load(data) ⇒ Object



27
28
29
30
# File 'lib/odania/config/domain.rb', line 27

def load(data)
	self.name = data['name'] unless data['name'].nil?
	self.add(data)
end

#subdomain(name) ⇒ Object



15
16
17
# File 'lib/odania/config/domain.rb', line 15

def subdomain(name)
	self.subdomains[name]
end