Sha256: 0408ac7bed0b61b85130a0aa3f7fb343654bff7a083e872b18371393c371f767

Contents?: true

Size: 671 Bytes

Versions: 40

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

# = Active Storage \Blob \Identifiable
module ActiveStorage::Blob::Identifiable
  def identify
    identify_without_saving
    save!
  end

  def identify_without_saving
    unless identified?
      self.content_type = identify_content_type
      self.identified = true
    end
  end

  def identified?
    identified
  end

  private
    def identify_content_type
      Marcel::MimeType.for download_identifiable_chunk, name: filename.to_s, declared_type: content_type
    end

    def download_identifiable_chunk
      if byte_size.positive?
        service.download_chunk key, 0...4.kilobytes
      else
        ""
      end
    end
end

Version data entries

40 entries across 40 versions & 5 rubygems

Version Path
activestorage-8.0.2 app/models/active_storage/blob/identifiable.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activestorage-7.1.3.4/app/models/active_storage/blob/identifiable.rb
activestorage-8.0.1 app/models/active_storage/blob/identifiable.rb
activestorage-8.0.0.1 app/models/active_storage/blob/identifiable.rb
activestorage-7.2.2.1 app/models/active_storage/blob/identifiable.rb
activestorage-7.1.5.1 app/models/active_storage/blob/identifiable.rb
activestorage-8.0.0 app/models/active_storage/blob/identifiable.rb
activestorage-7.2.2 app/models/active_storage/blob/identifiable.rb
activestorage-7.1.5 app/models/active_storage/blob/identifiable.rb
activestorage-8.0.0.rc2 app/models/active_storage/blob/identifiable.rb
activestorage-7.2.1.2 app/models/active_storage/blob/identifiable.rb
activestorage-7.1.4.2 app/models/active_storage/blob/identifiable.rb
activestorage-8.0.0.rc1 app/models/active_storage/blob/identifiable.rb
activestorage-7.2.1.1 app/models/active_storage/blob/identifiable.rb
activestorage-7.1.4.1 app/models/active_storage/blob/identifiable.rb
activestorage-8.0.0.beta1 app/models/active_storage/blob/identifiable.rb
omg-activestorage-8.0.0.alpha9 app/models/active_storage/blob/identifiable.rb
omg-activestorage-8.0.0.alpha8 app/models/active_storage/blob/identifiable.rb
omg-activestorage-8.0.0.alpha7 app/models/active_storage/blob/identifiable.rb
omg-activestorage-8.0.0.alpha4 app/models/active_storage/blob/identifiable.rb