Class: Odania::Config::PageBase
- Inherits:
-
Object
- Object
- Odania::Config::PageBase
- Defined in:
- lib/odania/config/page_base.rb
Instance Attribute Summary collapse
-
#direct ⇒ Object
Returns the value of attribute direct.
-
#dynamic ⇒ Object
Returns the value of attribute dynamic.
Instance Method Summary collapse
- #[](type) ⇒ Object
- #add(data, group_name = nil) ⇒ Object
- #dump ⇒ Object
-
#initialize ⇒ PageBase
constructor
A new instance of PageBase.
- #load(data, group_name) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ PageBase
Returns a new instance of PageBase.
6 7 8 |
# File 'lib/odania/config/page_base.rb', line 6 def initialize reset end |
Instance Attribute Details
#direct ⇒ Object
Returns the value of attribute direct.
4 5 6 |
# File 'lib/odania/config/page_base.rb', line 4 def direct @direct end |
#dynamic ⇒ Object
Returns the value of attribute dynamic.
4 5 6 |
# File 'lib/odania/config/page_base.rb', line 4 def dynamic @dynamic end |
Instance Method Details
#[](type) ⇒ Object
39 40 41 42 |
# File 'lib/odania/config/page_base.rb', line 39 def [](type) return self.direct if 'direct'.eql? type.to_s self.dynamic end |
#add(data, group_name = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/odania/config/page_base.rb', line 10 def add(data, group_name=nil) duplicates = Hash.new { |hash, key| hash[key] = [] } unless data['direct'].nil? data['direct'].each_pair do |name, direct_data| duplicates[:direct] << name if self.direct.key? name self.direct[name].load(direct_data, group_name) end end unless data['dynamic'].nil? data['dynamic'].each_pair do |name, dynamic_data| duplicates[:dynamic] << name if self.direct.key? name self.dynamic[name].load(dynamic_data, group_name) end end duplicates end |
#dump ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/odania/config/page_base.rb', line 44 def dump direct_data = {} direct.each_pair do |web_url, page| direct_data[web_url] = page.dump end dynamic_data = {} dynamic.each_pair do |web_url, page| dynamic_data[web_url] = page.dump end { 'direct' => direct_data, 'dynamic' => dynamic_data } end |
#load(data, group_name) ⇒ Object
28 29 30 |
# File 'lib/odania/config/page_base.rb', line 28 def load(data, group_name) self.add(data, group_name) end |
#reset ⇒ Object
32 33 34 35 36 37 |
# File 'lib/odania/config/page_base.rb', line 32 def reset self.direct = Hash.new { |hash, key| hash[key] = Page.new } self.dynamic = Hash.new { |hash, key| hash[key] = Page.new } @plugins = {:direct => Hash.new { |hash, key| hash[key] = [] }, :dynamic => Hash.new { |hash, key| hash[key] = [] }} end |