Class: Adva::Static::Import::Model::Blog

Inherits:
Section
  • Object
show all
Defined in:
lib/adva/static/import/model/blog.rb

Instance Attribute Summary

Attributes inherited from Section

#parent

Attributes inherited from Base

#source

Instance Method Summary collapse

Methods inherited from Section

#initialize, #parent_id, #record, #site, #site_id, #type

Methods inherited from Base

#attribute?, #attribute_value, #attributes, #initialize, #model, #model_name, #updated_record

Constructor Details

This class inherits a constructor from Adva::Static::Import::Model::Section

Instance Method Details

#attribute_namesObject



12
13
14
# File 'lib/adva/static/import/model/blog.rb', line 12

def attribute_names
  @attribute_names ||= super - [:categories, :posts]
end

#categoriesObject



16
17
18
# File 'lib/adva/static/import/model/blog.rb', line 16

def categories
  @categories ||= source.categories.map { |category| Category.new(:name => category, :section => record) }
end

#postsObject



20
21
22
# File 'lib/adva/static/import/model/blog.rb', line 20

def posts
  @posts ||= source.posts.map { |post| Post.new(post, self) }
end

#update!Object



6
7
8
9
10
# File 'lib/adva/static/import/model/blog.rb', line 6

def update!
  super
  categories.each { |category| category.save! }
  posts.each { |post| post.update! }
end