Last active
August 29, 2015 14:03
-
-
Save hemju/94713cacdbac9d08071d to your computer and use it in GitHub Desktop.
Revisions
-
Helmut Michael Juskewycz revised this gist
Jun 27, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,5 +22,6 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_ # maybe reload already returns the resource_import new and we don't need the last line at all? resource_import.reload # implicit returns always felt 'dirty' to me. For example ActiveRecord callbacks which return false # break the chain, so you have to know that to not break it unintentionally resource_import.reload resource_import end -
Helmut Michael Juskewycz revised this gist
Jun 26, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_attributes = {}, options = {}) # probably file_path is a String and the result file_name as well file_name = File.basename(file_path) # no idea what tempfile is, a string? tempfile = write_to_temp_file(content, file_name) uploaded_file = OpenStruct.new(:original_filename => file_name, :tempfile => tempfile) # Is this now an instance of ResourceImport or a result of a resource import? resource_import = ResourceImport.import!(user, project, uploaded_file, file_path, import_type, strategy_name, additional_attributes) # Ok, nothing ambiguous here resource_uploader = ResourceUploader.new(resource_import) resource_uploader.store!(tempfile) @@ -19,8 +19,8 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_ import_resource_import(resource_import) end # maybe reload already returns the resource_import new and we don't need the last line at all? resource_import.reload # implicit returns always felt 'dirty' to me. For example ActiveRecord callbacks which return false # break the chain, so you have to know that to not break it unintentionally resource_import end -
Helmut Michael Juskewycz revised this gist
Jun 26, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,7 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_ import_resource_import(resource_import) end // maybe reload already returns the resource_import new and we don't need the last line at all? resource_import.reload // implicit returns always felt 'dirty' to me. For example ActiveRecord callbacks which return false // break the chain, so you have to know that to not break it unintentionally resource_import -
Helmut Michael Juskewycz revised this gist
Jun 26, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,6 +22,6 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_ // maybe reload already returns the resource_import new and we don't need the last line at all? resource_import.reload // implicit returns always felt 'dirty' to me. For example ActiveRecord callbacks which return false // break the chain, so you have to know that to not break it unintentionally resource_import end -
Helmut Michael Juskewycz revised this gist
Jun 26, 2014 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,15 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_attributes = {}, options = {}) // probably file_path is a String and the result file_name as well file_name = File.basename(file_path) // no idea what tempfile is, a string? tempfile = write_to_temp_file(content, file_name) uploaded_file = OpenStruct.new(:original_filename => file_name, :tempfile => tempfile) // Is this now an instance of ResourceImport or a result of a resource import? resource_import = ResourceImport.import!(user, project, uploaded_file, file_path, import_type, strategy_name, additional_attributes) // Ok, nothing ambiguous here resource_uploader = ResourceUploader.new(resource_import) resource_uploader.store!(tempfile) @@ -15,6 +19,9 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_ import_resource_import(resource_import) end // maybe reload already returns the resource_import new and we don't need the last line at all? resource_import.reload // implicit returns always felt 'dirty' to me. For example ActiveRecord callbacks which return false // break the cahain resource_import end -
Helmut Michael Juskewycz created this gist
Jun 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ def import_file_data(file_path, content, import_type, strategy_name, additional_attributes = {}, options = {}) file_name = File.basename(file_path) tempfile = write_to_temp_file(content, file_name) uploaded_file = OpenStruct.new(:original_filename => file_name, :tempfile => tempfile) resource_import = ResourceImport.import!(user, project, uploaded_file, file_path, import_type, strategy_name, additional_attributes) resource_uploader = ResourceUploader.new(resource_import) resource_uploader.store!(tempfile) if options.fetch(:schedule, true) ResourceImportsService.new.schedule_import(resource_import) else import_resource_import(resource_import) end resource_import.reload resource_import end