Class: Ecm::Cms::Importers::Page
- Inherits:
-
Object
- Object
- Ecm::Cms::Importers::Page
- Defined in:
- lib/ecm/cms/importers/page.rb
Instance Attribute Summary collapse
-
#yaml ⇒ Object
readonly
Returns the value of attribute yaml.
Instance Method Summary collapse
- #build_pages ⇒ Object
- #extract_navigation_items(navigation_item_data) ⇒ Object
-
#initialize(yaml, _option = {}) ⇒ Page
constructor
A new instance of Page.
- #pages ⇒ Object
Constructor Details
#initialize(yaml, _option = {}) ⇒ Page
Returns a new instance of Page.
5 6 7 8 |
# File 'lib/ecm/cms/importers/page.rb', line 5 def initialize(yaml, _option = {}) @pages = nil @yaml = YAML.load(yaml) end |
Instance Attribute Details
#yaml ⇒ Object (readonly)
Returns the value of attribute yaml.
34 35 36 |
# File 'lib/ecm/cms/importers/page.rb', line 34 def yaml @yaml end |
Instance Method Details
#build_pages ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ecm/cms/importers/page.rb', line 10 def build_pages pages = [] @yaml.each do |page_data| = (page_data.delete('navigation_items')) page = Ecm::Cms::Page.new(page_data) page. = .map(&:id) pages << page end if @yaml.respond_to?(:each) pages end |
#extract_navigation_items(navigation_item_data) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ecm/cms/importers/page.rb', line 21 def () = [] .each do |nid| = Ecm::Cms::Navigation.where(locale: nid['navigation_locale'], name: nid['navigation_name']).first << ..where(name: nid['name']).first if .respond_to?(:ecm_cms_navigation_items) end end |
#pages ⇒ Object
30 31 32 |
# File 'lib/ecm/cms/importers/page.rb', line 30 def pages @pages ||= build_pages end |