Class: Railspress::PostExportProcessor

Inherits:
Object
  • Object
show all
Defined in:
app/models/railspress/post_export_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(export:) ⇒ PostExportProcessor

Returns a new instance of PostExportProcessor.



8
9
10
11
12
# File 'app/models/railspress/post_export_processor.rb', line 8

def initialize(export:)
  @export = export
  @errors = []
  @export_dir = nil
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'app/models/railspress/post_export_processor.rb', line 6

def errors
  @errors
end

#exportObject (readonly)

Returns the value of attribute export.



6
7
8
# File 'app/models/railspress/post_export_processor.rb', line 6

def export
  @export
end

#export_dirObject (readonly)

Returns the value of attribute export_dir.



6
7
8
# File 'app/models/railspress/post_export_processor.rb', line 6

def export_dir
  @export_dir
end

Instance Method Details

#process!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/railspress/post_export_processor.rb', line 14

def process!
  export.mark_processing!

  setup_export_directory
  export_all_posts
  create_zip_file

  if export.error_count > 0 && export.success_count == 0
    export.mark_failed!
  else
    export.mark_completed!
  end
ensure
  cleanup_export_directory
end