Class: FedoraMigrate::Mover

Inherits:
Object
  • Object
show all
Includes:
Hooks, MigrationOptions
Defined in:
lib/fedora_migrate/mover.rb

Instance Attribute Summary collapse

Attributes included from MigrationOptions

#conversions, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooks

#after_datastream_migration, #after_object_migration, #after_rdf_datastream_migration, #before_datastream_migration, #before_object_migration, #before_rdf_datastream_migration

Methods included from MigrationOptions

#application_creates_versions?, #blacklist, #conversion_options, #forced?, #not_forced?

Constructor Details

#initialize(*args) ⇒ Mover

Returns a new instance of Mover.



8
9
10
11
12
13
14
# File 'lib/fedora_migrate/mover.rb', line 8

def initialize(*args)
  @source = args[0]
  @target = args[1]
  @options = args[2]
  @report = results_report
  post_initialize
end

Instance Attribute Details

#reportObject

Returns the value of attribute report.



6
7
8
# File 'lib/fedora_migrate/mover.rb', line 6

def report
  @report
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/fedora_migrate/mover.rb', line 6

def source
  @source
end

#targetObject

Returns the value of attribute target.



6
7
8
# File 'lib/fedora_migrate/mover.rb', line 6

def target
  @target
end

Class Method Details

.id_component(object) ⇒ Object



45
46
47
48
49
# File 'lib/fedora_migrate/mover.rb', line 45

def self.id_component(object)
  return object.pid.split(/:/).last if object.is_a?(Rubydora::DigitalObject)
  return object.to_s.split(/:/).last if object.respond_to?(:to_s)
  nil
end

Instance Method Details

#id_component(object = nil) ⇒ Object



39
40
41
42
43
# File 'lib/fedora_migrate/mover.rb', line 39

def id_component(object = nil)
  object ||= source
  raise FedoraMigrate::Errors::MigrationError, "can't get the id component without an object" if object.nil?
  self.class.id_component(object)
end

#migrateObject



23
24
25
# File 'lib/fedora_migrate/mover.rb', line 23

def migrate
  report
end

#post_initializeObject



16
17
# File 'lib/fedora_migrate/mover.rb', line 16

def post_initialize
end

#results_reportObject



19
20
21
# File 'lib/fedora_migrate/mover.rb', line 19

def results_report
  []
end

#saveObject



27
28
29
# File 'lib/fedora_migrate/mover.rb', line 27

def save
  raise FedoraMigrate::Errors::MigrationError, "Failed to save target: #{target_errors}" unless target.save
end

#target_errorsObject



31
32
33
34
35
36
37
# File 'lib/fedora_migrate/mover.rb', line 31

def target_errors
  if target.respond_to?(:errors)
    target.errors.full_messages.join(" -- ")
  else
    target.inspect
  end
end