Class: ComfortableMexicanSofa::Fixture::Category::Exporter

Inherits:
Exporter
  • Object
show all
Defined in:
lib/comfortable_mexican_sofa/fixture/category.rb

Instance Attribute Summary

Attributes inherited from Exporter

#from, #path, #site, #to

Instance Method Summary collapse

Methods inherited from Exporter

#initialize, #prepare_folder!

Constructor Details

This class inherits a constructor from ComfortableMexicanSofa::Fixture::Exporter

Instance Method Details

#export!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/comfortable_mexican_sofa/fixture/category.rb', line 20

def export!
  prepare_folder!(self.path)
  {
    'files'     => 'Comfy::Cms::File',
    'pages'     => 'Comfy::Cms::Page',
    'snippets'  => 'Comfy::Cms::Snippet'
  }.each do |file, type|
    if (categories = self.site.categories.of_type(type)).present?
      open(File.join(self.path, "#{file}.yml"), 'w') do |f|
        f.write(categories.map{|c| c.label}.to_yaml)
      end
    end
  end
end