lib/saviour/base_uploader.rb in saviour-0.4.14 vs lib/saviour/base_uploader.rb in saviour-0.5.0
- old
+ new
@@ -3,10 +3,11 @@
module Saviour
class BaseUploader
def initialize(opts = {})
@data = opts.fetch(:data, {})
+ @stash = {}
end
def method_missing(name, *args, &block)
if @data.key?(name)
@data[name]
@@ -49,10 +50,18 @@
def halt_process
throw(:halt_process)
end
+ def stash(hash)
+ @stash.merge!(hash)
+ end
+
+ def stashed
+ @stash
+ end
+
def store_dir
@store_dir ||= Uploader::StoreDirExtractor.new(self).store_dir
end
class << self
@@ -74,12 +83,19 @@
def process_with_file(name = nil, opts = {}, &block)
process(name, opts, :file, &block)
end
-
def store_dir(name = nil, &block)
store_dirs.push(name || block)
+ end
+
+ def after_upload(&block)
+ after_upload_hooks.push(block)
+ end
+
+ def after_upload_hooks
+ @after_upload ||= []
end
end
end
end