Sha256: 2449a4ae41a1425ba2507fa131341e84ea2f5a8d739ce1191cbed60c1efd7e7d

Contents?: true

Size: 932 Bytes

Versions: 27

Compression:

Stored size: 932 Bytes

Contents

module Ddr
  module Actions
    class FixityCheck

      # Return result of fixity check - wrapped by a notifier
      def self.execute(object)
        ActiveSupport::Notifications.instrument(Ddr::Notifications::FIXITY_CHECK) do |payload|
          payload[:result] = _execute(object)
        end
      end

      # Return result of fixity check
      def self._execute(object)
        Result.new(pid: object.pid).tap do |r|
          object.datastreams_to_validate.each do |dsid, ds|
            r.success &&= ds.dsChecksumValid
            r.results[dsid] = ds.profile
          end
        end
      end

      class Result
        attr_accessor :pid, :success, :results, :checked_at

        def initialize(args={})
          @pid = args[:pid]
          @success = args[:success] || true
          @results = args[:results] || {}
          @checked_at = args[:checked_at] || Time.now.utc
        end
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ddr-models-1.13.2 lib/ddr/actions/fixity_check.rb
ddr-models-1.13.1 lib/ddr/actions/fixity_check.rb
ddr-models-1.13.0 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.8 lib/ddr/actions/fixity_check.rb
ddr-models-1.12.3 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.7 lib/ddr/actions/fixity_check.rb
ddr-models-1.12.2 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.6 lib/ddr/actions/fixity_check.rb
ddr-models-1.12.1 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.5 lib/ddr/actions/fixity_check.rb
ddr-models-1.12.0 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.4 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.3 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.2 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.1 lib/ddr/actions/fixity_check.rb
ddr-models-1.11.0 lib/ddr/actions/fixity_check.rb
ddr-models-1.10.0 lib/ddr/actions/fixity_check.rb
ddr-models-1.9.0 lib/ddr/actions/fixity_check.rb
ddr-models-1.8.1 lib/ddr/actions/fixity_check.rb
ddr-models-1.8.0 lib/ddr/actions/fixity_check.rb