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.



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

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.



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

def report
  @report
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

Class Method Details

.id_component(object) ⇒ Object



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

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

Instance Method Details

#id_component(object = nil) ⇒ Object



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

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



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

def migrate
  report
end

#post_initializeObject



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

def post_initialize
end

#results_reportObject



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

def results_report
  []
end

#saveObject



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

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

#target_errorsObject



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

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