Class: Odania::Config::PageBase
- Inherits:
-
Object
- Object
- Odania::Config::PageBase
- Defined in:
- lib/odania/config/page_base.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
Returns the value of attribute assets.
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
#assets ⇒ Object
Returns the value of attribute assets.
4 5 6 |
# File 'lib/odania/config/page_base.rb', line 4 def assets @assets end |
Instance Method Details
#[](type) ⇒ Object
31 32 33 |
# File 'lib/odania/config/page_base.rb', line 31 def [](type) self.assets end |
#add(data, group_name = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/odania/config/page_base.rb', line 10 def add(data, group_name=nil) duplicates = Hash.new { |hash, key| hash[key] = [] } unless data['assets'].nil? data['assets'].each_pair do |name, asset_data| duplicates[:assets] << name if self.assets.key? name self.assets[name].load(asset_data, group_name) end end duplicates end |
#dump ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/odania/config/page_base.rb', line 35 def dump asset_data = {} assets.each_pair do |web_url, page| asset_data[web_url] = page.dump end { 'assets' => asset_data } end |
#load(data, group_name) ⇒ Object
21 22 23 |
# File 'lib/odania/config/page_base.rb', line 21 def load(data, group_name) self.add(data, group_name) end |
#reset ⇒ Object
25 26 27 28 29 |
# File 'lib/odania/config/page_base.rb', line 25 def reset self.assets = Hash.new { |hash, key| hash[key] = Page.new } @plugins = {:assets => Hash.new { |hash, key| hash[key] = [] }} end |