Class: ExportJob

Inherits:
Struct
  • Object
show all
Defined in:
app/jobs/export_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri

Returns:

  • (Object)

    the current value of base_uri



1
2
3
# File 'app/jobs/export_job.rb', line 1

def base_uri
  @base_uri
end

#exportObject

Returns the value of attribute export

Returns:

  • (Object)

    the current value of export



1
2
3
# File 'app/jobs/export_job.rb', line 1

def export
  @export
end

#filenameObject

Returns the value of attribute filename

Returns:

  • (Object)

    the current value of filename



1
2
3
# File 'app/jobs/export_job.rb', line 1

def filename
  @filename
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



1
2
3
# File 'app/jobs/export_job.rb', line 1

def type
  @type
end

Instance Method Details

#enqueue(job) ⇒ Object



2
3
4
5
6
7
# File 'app/jobs/export_job.rb', line 2

def enqueue(job)
  job.delayed_reference_id   = export.id
  job.delayed_reference_type = export.class.to_s
  job.delayed_global_reference_id = export.to_global_id
  job.save!
end

#error(job, exception) ⇒ Object



21
22
23
# File 'app/jobs/export_job.rb', line 21

def error(job, exception)
  export.fail!(exception)
end

#performObject



9
10
11
12
13
14
15
# File 'app/jobs/export_job.rb', line 9

def perform
  strio = StringIO.new

  exporter = SkosExporter.new(filename, type, base_uri, Logger.new(strio))
  exporter.run
  @messages = strio.string
end

#success(job) ⇒ Object



17
18
19
# File 'app/jobs/export_job.rb', line 17

def success(job)
  export.finish!(@messages)
end