Sha256: 06a071a3883f65585933657f31d99287baa56c210c8d7a720378f2ddde6cab91

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module Ddr
  module Models
    module HasAdminMetadata
      extend ActiveSupport::Concern

      included do
        has_metadata "adminMetadata",
                     type: Ddr::Datastreams::AdministrativeMetadataDatastream,
                     versionable: true,
                     control_group: "M"

        has_attributes :permanent_id, :permanent_url, :workflow_state,
                       datastream: "adminMetadata", multiple: false

        delegate :principal_has_role?, to: :roles
        delegate :publish, :publish!, :unpublish, :unpublish!, :published?, to: :workflow

        after_create :assign_permanent_id!, if: "Ddr::Models.auto_assign_permanent_ids"
      end

      def permanent_id_manager
        @permanent_id_manager ||= Ddr::Managers::PermanentIdManager.new(self)
      end

      def roles
        @roles ||= Ddr::Managers::RoleManager.new(self)
      end

      def workflow
        @workflow ||= Ddr::Managers::WorkflowManager.new(self)
      end

      def assign_permanent_id!
        permanent_id_manager.assign_later
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddr-models-1.12.3 lib/ddr/models/has_admin_metadata.rb
ddr-models-1.12.2 lib/ddr/models/has_admin_metadata.rb
ddr-models-1.12.1 lib/ddr/models/has_admin_metadata.rb
ddr-models-1.12.0 lib/ddr/models/has_admin_metadata.rb