Sha256: ebd9312b392c22e74fe92045fd26530b8d092c4cc507b03fb5393a66e15b9c70

Contents?: true

Size: 952 Bytes

Versions: 22

Compression:

Stored size: 952 Bytes

Contents

module ActiveFedora
  # Helps Rubydora create datastreams of the type defined by the ActiveFedora::Base#datastream_class_for_name
  class UnsavedDigitalObject 
    attr_accessor :original_class, :ownerId, :datastreams, :label, :namespace
    
    def initialize(original_class, namespace, pid=nil)
      @pid = pid
      self.original_class = original_class
      self.namespace = namespace
      self.datastreams = {}
    end

    def pid
      @pid || '__DO_NOT_USE__'
    end

    def new?
      true
    end

    ### Change this into a real digital object
    def save
      obj = DigitalObject.find(self.original_class, assign_pid)
      self.datastreams.each do |k, v|
        v.digital_object = obj
        obj.datastreams[k] = v
      end
      obj.ownerId = ownerId if ownerId
      obj.label = label if label
      obj
    end

    def assign_pid
        return @pid if @pid
        self.original_class.assign_pid(self)
    end



  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
active-fedora-4.1.0 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc20 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc19 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc18 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc17 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc16 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc15 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc14 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc13 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc12 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc11 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc10 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc9 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc8 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc7 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc6 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc5 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc4 lib/active_fedora/unsaved_digital_object.rb
active-fedora-4.0.0.rc3 lib/active_fedora/unsaved_digital_object.rb