module Shrine::Plugins::Signature::ClassMethods

Public Instance Methods

calculate_signature(io, algorithm, format: :hex, rewind: true) click to toggle source

Calculates ‘algorithm` hash of the contents of the IO object, and encodes it into `format`.

# File lib/shrine/plugins/signature.rb, line 24
def calculate_signature(io, algorithm, format: :hex, rewind: true)
  calculator = SignatureCalculator.new(algorithm.downcase, format: format)

  signature = instrument_signature(io, algorithm, format) { calculator.call(io) }
  io.rewind if rewind

  signature
end
Also aliased as: signature
signature(io, algorithm, format: :hex, rewind: true)
Alias for: calculate_signature

Private Instance Methods

instrument_signature(io, algorithm, format) { || ... } click to toggle source

Sends a ‘signature.shrine` event for instrumentation plugin.

# File lib/shrine/plugins/signature.rb, line 37
def instrument_signature(io, algorithm, format, &block)
  return yield unless respond_to?(:instrument)

  instrument(:signature, io: io, algorithm: algorithm, format: format, &block)
end