Class: ComfortableMexicanSofa::Seeds::Layout::Importer

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

Instance Attribute Summary

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.


6
7
8
9
# File 'lib/comfortable_mexican_sofa/seeds/layout/importer.rb', line 6

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

Instance Method Details

#import!(path = self.path, parent = nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/comfortable_mexican_sofa/seeds/layout/importer.rb', line 11

def import!(path = self.path, parent = nil)
  Dir["#{path}*/"].each do |layout_path|
    import_layout(layout_path, parent)
  end

  # cleaning up
  site.layouts.where("id NOT IN (?)", seed_ids).destroy_all
end