Class: ComfortableMexicanSofa::Seeds::Page::Importer

Inherits:
Importer
  • Object
show all
Defined in:
lib/comfortable_mexican_sofa/seeds/page/importer.rb

Instance Attribute Summary collapse

Attributes inherited from Importer

#from, #path, #seed_ids, #site, #to

Instance Method Summary collapse

Constructor Details

#initialize(from, to = from) ⇒ Importer

Returns a new instance of Importer.


10
11
12
13
# File 'lib/comfortable_mexican_sofa/seeds/page/importer.rb', line 10

def initialize(from, to = from)
  super
  self.path = ::File.join(ComfortableMexicanSofa.config.seeds_path, from, "pages/")
end

Instance Attribute Details

#target_pagesObject

tracking target page linking. Since we might be linking to something that doesn't exist yet, we'll defer linking to the end of import


8
9
10
# File 'lib/comfortable_mexican_sofa/seeds/page/importer.rb', line 8

def target_pages
  @target_pages
end

Instance Method Details

#import!Object


15
16
17
18
19
20
21
22
# File 'lib/comfortable_mexican_sofa/seeds/page/importer.rb', line 15

def import!
  import_page(File.join(path, "index/"), nil)

  link_target_pages

  # Remove pages not found in seeds
  site.pages.where("id NOT IN (?)", seed_ids).destroy_all
end