Sha256: 18bd6e34e32518afa2399be39b7006f8426690fa565a48965ad7efab5d981060

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

# Naive implementation of IO wrapper class that adds mime_type and original_filename
# attributes. This is done to match the interface of ActionDispatch::HTTP::UploadedFile
# so the attributes do not have to be passed as additional arguments, and are attached
# properly to the object they describe.
#
#
#  Use SimpleDelegator to wrap the given class or instance
require 'delegate'

module Hydra
  module Derivatives
    class IoDecorator < SimpleDelegator
      extend Deprecation

      attr_accessor :mime_type, :original_filename
      alias original_name original_filename
      deprecation_deprecate original_name: 'original_name has been deprecated. Use original_filename instead. This will be removed in hydra-derivatives 4.0'
      alias original_name= original_filename=
      deprecation_deprecate :"original_name=" => 'original_name= has been deprecated. Use original_filename= instead. This will be removed in hydra-derivatives 4.0'

      def initialize(file, mime_type = nil, original_filename = nil)
        super(file)
        self.mime_type = mime_type
        self.original_filename = original_filename
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hydra-derivatives-3.7.0 lib/hydra/derivatives/io_decorator.rb
hydra-derivatives-3.6.1 lib/hydra/derivatives/io_decorator.rb
hydra-derivatives-3.6.0 lib/hydra/derivatives/io_decorator.rb
hydra-derivatives-3.5.0 lib/hydra/derivatives/io_decorator.rb
hydra-derivatives-3.4.2 lib/hydra/derivatives/io_decorator.rb
hydra-derivatives-3.4.1 lib/hydra/derivatives/io_decorator.rb