Class: Odania::Config::SubDomain
- Defined in:
- lib/odania/config/sub_domain.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#dynamic ⇒ Object
Returns the value of attribute dynamic.
-
#from_plugin ⇒ Object
Returns the value of attribute from_plugin.
-
#internal ⇒ Object
Returns the value of attribute internal.
-
#name ⇒ Object
Returns the value of attribute name.
-
#redirects ⇒ Object
Returns the value of attribute redirects.
Attributes inherited from PageBase
Instance Method Summary collapse
- #add(data, group_name = nil) ⇒ Object
- #add_page(type, web_url, group_name, url_data, plugin_name) ⇒ Object
- #assets ⇒ Object
- #dump ⇒ Object
- #get_redirects ⇒ Object
-
#initialize(name) ⇒ SubDomain
constructor
A new instance of SubDomain.
- #load(data) ⇒ Object
- #plugins(type, key) ⇒ Object
- #set_config(config_data, group_name) ⇒ Object
Methods inherited from PageBase
Constructor Details
#initialize(name) ⇒ SubDomain
Returns a new instance of SubDomain.
6 7 8 9 |
# File 'lib/odania/config/sub_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/sub_domain.rb', line 4 def config @config end |
#dynamic ⇒ Object
Returns the value of attribute dynamic.
4 5 6 |
# File 'lib/odania/config/sub_domain.rb', line 4 def dynamic @dynamic end |
#from_plugin ⇒ Object
Returns the value of attribute from_plugin.
4 5 6 |
# File 'lib/odania/config/sub_domain.rb', line 4 def from_plugin @from_plugin end |
#internal ⇒ Object
Returns the value of attribute internal.
4 5 6 |
# File 'lib/odania/config/sub_domain.rb', line 4 def internal @internal end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/odania/config/sub_domain.rb', line 4 def name @name end |
#redirects ⇒ Object
Returns the value of attribute redirects.
4 5 6 |
# File 'lib/odania/config/sub_domain.rb', line 4 def redirects @redirects end |
Instance Method Details
#add(data, group_name = nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/odania/config/sub_domain.rb', line 62 def add(data, group_name=nil) duplicates = super(data, group_name) self.config = data['config'] unless data['config'].nil? self.internal.load(data['internal'], group_name) unless data['internal'].nil? unless data['redirects'].nil? data['redirects'].each_pair do |src_url, target_url| duplicates[:redirect] << src_url if self.redirects.key? src_url self.redirects[src_url] = target_url end end duplicates end |
#add_page(type, web_url, group_name, url_data, plugin_name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/odania/config/sub_domain.rb', line 23 def add_page(type, web_url, group_name, url_data, plugin_name) result = true result = false unless self.pages[type].key? web_url self.pages[type][web_url].group_name = group_name self.pages[type][web_url].plugin_url = url_data['plugin_url'] self.pages[type][web_url].cacheable = url_data['cacheable'] unless url_data['cacheable'].nil? self.pages[type][web_url].expires = url_data['expires'] unless url_data['expires'].nil? @plugins[:page]["#{type}-#{web_url}"] << plugin_name result end |
#assets ⇒ Object
43 44 45 |
# File 'lib/odania/config/sub_domain.rb', line 43 def assets self.internal.assets end |
#dump ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/odania/config/sub_domain.rb', line 47 def dump result = super result['redirects'] = self.redirects result['config'] = self.config result['internal'] = self.internal.dump result end |
#get_redirects ⇒ Object
34 35 36 37 |
# File 'lib/odania/config/sub_domain.rb', line 34 def get_redirects return {} if self.redirects.nil? self.redirects end |
#load(data) ⇒ Object
56 57 58 59 60 |
# File 'lib/odania/config/sub_domain.rb', line 56 def load(data) reset super(data, nil) self.add(data) end |
#plugins(type, key) ⇒ Object
39 40 41 |
# File 'lib/odania/config/sub_domain.rb', line 39 def plugins(type, key) @plugins[type][key] end |
#set_config(config_data, group_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/odania/config/sub_domain.rb', line 11 def set_config(config_data, group_name) errors = [] return errors if config_data.nil? config_data.each_pair do |key, val| from_plugin[:config][key] << group_name errors << {:type => :config, :plugins => from_plugin[:config][key], :key => key} unless config[key].nil? config[key] = val end errors end |