Sha256: 38607fe12454b9742f047aeb006a960d4a6be17802c30a2b1b49cafced502d61

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

module CurationConcern
  class MockCurationConcernActor < CurationConcern::BaseActor

    def create!
      super
      create_thesis_file
      assign_doi_if_applicable
    end

    def update!
      super
      update_contained_generic_file_visibility
      assign_doi_if_applicable
    end

    protected
    def thesis_file
      return @thesis_file if defined?(@thesis_file)
      @thesis_file = attributes.delete(:thesis_file)
    end

    def create_thesis_file
      if thesis_file
        generic_file = GenericFile.new
        generic_file.file = thesis_file
        generic_file.batch = curation_concern
        generic_file.label = curation_concern.human_readable_type
        Sufia::GenericFile::Actions.create_metadata(
          generic_file, user, curation_concern.pid
        )
        generic_file.set_visibility(visibility)
        CurationConcern.attach_file(generic_file, user, thesis_file)
      end
    end

    def update_contained_generic_file_visibility
      if visibility_may_have_changed?
        curation_concern.generic_files.each do |f|
          f.set_visibility(visibility)
          f.save!
        end
      end
    end

    def assign_doi_if_applicable
      if attributes[:assign_doi].to_i != 0
        doi_minter.call(curation_concern.pid)
      end
    end

    include Morphine
    register :doi_minter do
      lambda { |pid|
        Sufia.queue.push(DoiWorker.new(pid))
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
curate-0.3.2 spec/dummy/app/services/curation_concern/mock_curation_concern_actor.rb
curate-0.3.1 spec/dummy/app/services/curation_concern/mock_curation_concern_actor.rb
curate-0.2.0 spec/dummy/app/services/curation_concern/mock_curation_concern_actor.rb
curate-0.1.3 spec/dummy/app/services/curation_concern/mock_curation_concern_actor.rb
curate-0.1.2 spec/dummy/app/services/curation_concern/mock_curation_concern_actor.rb