Class: ComfortableMexicanSofa::Fixture::Category::Importer
- Defined in:
- lib/comfortable_mexican_sofa/fixture/category.rb
Instance Attribute Summary
Attributes inherited from Importer
#fixture_ids, #force_import, #from, #path, #site, #to
Instance Method Summary collapse
Methods inherited from Importer
#fresh_fixture?, #get_attributes, #initialize, #save_categorizations!
Constructor Details
This class inherits a constructor from ComfortableMexicanSofa::Fixture::Importer
Instance Method Details
#import! ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/comfortable_mexican_sofa/fixture/category.rb', line 3 def import! { 'files' => 'Comfy::Cms::File', 'pages' => 'Comfy::Cms::Page', 'snippets' => 'Comfy::Cms::Snippet' }.each do |file, type| if File.exists?(attrs_path = File.join(path, "#{file}.yml")) categories = get_attributes(attrs_path) [categories].flatten.each do |label| self.site.categories.find_or_create_by(:label => label, :categorized_type => type) end end end end |