mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Hoist update for clarity
This commit is contained in:
parent
d94db07774
commit
9794e85351
2 changed files with 8 additions and 8 deletions
activestorage/app/models/active_storage
|
@ -2,10 +2,15 @@
|
|||
|
||||
module ActiveStorage::Blob::Identifiable
|
||||
def identify
|
||||
ActiveStorage::Identification.new(self).apply
|
||||
update!(content_type: identification.content_type, identified: true) unless identified?
|
||||
end
|
||||
|
||||
def identified?
|
||||
identified
|
||||
end
|
||||
|
||||
private
|
||||
def identification
|
||||
ActiveStorage::Identification.new self
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,16 +9,11 @@ class ActiveStorage::Identification #:nodoc:
|
|||
@blob = blob
|
||||
end
|
||||
|
||||
def apply
|
||||
blob.update!(content_type: content_type, identified: true) unless blob.identified?
|
||||
def content_type
|
||||
Marcel::MimeType.for(identifiable_chunk, name: filename, declared_type: declared_content_type)
|
||||
end
|
||||
|
||||
private
|
||||
def content_type
|
||||
Marcel::MimeType.for(identifiable_chunk, name: filename, declared_type: declared_content_type)
|
||||
end
|
||||
|
||||
|
||||
def identifiable_chunk
|
||||
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |client|
|
||||
client.get(uri, "Range" => "bytes=0-4095").body
|
||||
|
|
Loading…
Reference in a new issue