Skip to content

Instantly share code, notes, and snippets.

@xdougx
Last active May 16, 2016 19:46
Show Gist options
  • Save xdougx/801357ab0f24aef77481dd941f0c7986 to your computer and use it in GitHub Desktop.
Save xdougx/801357ab0f24aef77481dd941f0c7986 to your computer and use it in GitHub Desktop.
module Import
class Base
attr_accessor :type, :path, :file, :file_type
def initialize(params)
self.type = params[:type]
self.file = params[:file]
self.file_type = params[:file_type]
self.path = File.join(Rails.root, "public", self.file.original_filename)
end
def start
create
run
destroy
self
end
private
def create
File.open path, "wb" do |file|
file.write(self.file.read)
end
end
def run
# rola o import aqui
end
def destroy
system 'rm', path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment