Class: Odania::Config::Domain
- Inherits:
-
Object
- Object
- Odania::Config::Domain
- Defined in:
- lib/odania/config/domain.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#redirects ⇒ Object
Returns the value of attribute redirects.
-
#subdomains ⇒ Object
Returns the value of attribute subdomains.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add(sub_domain_data, group_name = nil) ⇒ Object
- #add_subdomain(subdomain_name) ⇒ Object
- #dump ⇒ Object
- #get_redirects ⇒ Object
-
#initialize(name) ⇒ Domain
constructor
A new instance of Domain.
- #load(data) ⇒ Object
- #subdomain(name) ⇒ Object
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
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/odania/config/domain.rb', line 4 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/odania/config/domain.rb', line 4 def name @name end |
#redirects ⇒ Object
Returns the value of attribute redirects.
4 5 6 |
# File 'lib/odania/config/domain.rb', line 4 def redirects @redirects end |
#subdomains ⇒ Object
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 |
#dump ⇒ Object
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_redirects ⇒ Object
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 |