Commit 50b68fc2 authored by Shinya Maeda's avatar Shinya Maeda

Use prepend to correctly use the monketpatch's method

parent b358d263
...@@ -5,6 +5,7 @@ module CarrierWave ...@@ -5,6 +5,7 @@ module CarrierWave
module Storage module Storage
class Fog < Abstract class Fog < Abstract
class File class File
module MonkeyPatch
def read def read
file_body = file.body file_body = file.body
...@@ -24,18 +25,21 @@ module CarrierWave ...@@ -24,18 +25,21 @@ module CarrierWave
new_file.copy_to(path) new_file.copy_to(path)
else else
fog_file = new_file.to_file fog_file = new_file.to_file
@content_type ||= new_file.content_type @content_type ||= new_file.content_type # rubocop:disable Gitlab/ModuleWithInstanceVariables
@file = directory.files.create({ @file = directory.files.create({ # rubocop:disable Gitlab/ModuleWithInstanceVariables
:body => fog_file ? fog_file : new_file.read, # rubocop:disable Gitlab/HashSyntax :body => fog_file ? fog_file : new_file.read, # rubocop:disable Gitlab/HashSyntax
:content_type => @content_type, # rubocop:disable Gitlab/HashSyntax :content_type => @content_type, # rubocop:disable Gitlab/HashSyntax,Gitlab/ModuleWithInstanceVariables
:key => path, # rubocop:disable Gitlab/HashSyntax :key => path, # rubocop:disable Gitlab/HashSyntax
:public => @uploader.fog_public # rubocop:disable Gitlab/HashSyntax :public => @uploader.fog_public # rubocop:disable Gitlab/HashSyntax,Gitlab/ModuleWithInstanceVariables
}.merge(@uploader.fog_attributes)) }.merge(@uploader.fog_attributes)) # rubocop:disable Gitlab/ModuleWithInstanceVariables
fog_file.close if fog_file && !fog_file.closed? fog_file.close if fog_file && !fog_file.closed?
end end
true true
end end
end end
prepend MonkeyPatch
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment