Sha256: 7055210824eaa8fa3be96bdababbd470bba4cb2545bb71fe1e1d3f34da64a5e1

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

require "active_storage/downloading"

module ActiveStorage
  # This is an abstract base class for analyzers, which extract metadata from blobs. See
  # ActiveStorage::Analyzer::ImageAnalyzer for an example of a concrete subclass.
  class Analyzer
    include Downloading

    attr_reader :blob

    # Implement this method in a concrete subclass. Have it return true when given a blob from which
    # the analyzer can extract metadata.
    def self.accept?(blob)
      false
    end

    def initialize(blob)
      @blob = blob
    end

    # Override this method in a concrete subclass. Have it return a Hash of metadata.
    def metadata
      raise NotImplementedError
    end

    private
      def logger
        ActiveStorage.logger
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activestorage-5.2.0.beta2 lib/active_storage/analyzer.rb
activestorage-5.2.0.beta1 lib/active_storage/analyzer.rb