Class: Workarea::Blog::Import::Wordpress::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/workarea/blog/import/wordpress/entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(post_hash, blog) ⇒ Entry

Returns a new instance of Entry.



8
9
10
11
# File 'lib/workarea/blog/import/wordpress/entry.rb', line 8

def initialize(post_hash, blog)
  @post_hash = post_hash
  @blog = blog
end

Instance Method Details

#saveObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/workarea/blog/import/wordpress/entry.rb', line 13

def save
  if Workarea::Content::BlogEntry.where(slug: @post_hash[:new_slug]).present?
    puts "An entry already exists with the slug #{@post_hash[:new_slug]}"
    return
  end
  create_entry
  create_redirects
  create_entry_content
  puts "Imported #{@entry.name}"
  @entry
end