Sha256: 0e136bbe66ece4a0c2057c4b2c695e973205d6530bf28ad89cedca88204301f6

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

module Hydra
  module Derivatives
    class Processor
      attr_accessor :object, :source_name, :directives

      def initialize(obj, source_name, directives)
        self.object = obj
        self.source_name = source_name
        self.directives = directives
      end

      def process
        raise "Processor is an abstract class. Implement `process' on #{self.class.name}"
      end

      def output_file_id(name)
        [source_name, name].join('_')
      end

      def output_file(path)
        # first, check for a defined file
        output_file = if object.attached_files[path]
          object.attached_files[path]
        else
          ActiveFedora::File.new("#{object.uri}/#{path}").tap do |file|
            object.attach_file(file, path)
          end
        end
      end

      def source_file
        object.attached_files[source_name.to_s]
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-derivatives-1.2.1 lib/hydra/derivatives/processor.rb
hydra-derivatives-1.2.0 lib/hydra/derivatives/processor.rb
hydra-derivatives-1.1.0 lib/hydra/derivatives/processor.rb