lib/carrierwave/processor/injector.rb in carrierwave-processor-1.0.2 vs lib/carrierwave/processor/injector.rb in carrierwave-processor-1.0.3
- old
+ new
@@ -1,13 +1,16 @@
require 'delegate'
require 'active_support/core_ext/class'
class Injector < Module
+ # PLUGIN_OPTIONS = [:outer_version, :root_uploader]
+
def initialize uploader, opts = {}, &block
@uploader = uploader
@outer_version = opts.delete(:outer_version)
+ @root_uploader = opts.delete(:root_uploader)
@options = opts
self.class_eval &block
@uploader.prepend self
end
@@ -28,11 +31,12 @@
version_options[:if] = new_if
version_options.delete :if if version_options[:if].nil?
version_options[:from_version] = @outer_version if @outer_version
passing_options = {:if => ifs_array}
passing_options[:outer_version] = args.first if args.first
+ passing_options[:root_uploader] = @root_uploader || @uploader
version_args = version_options.empty? ? args : (args + [version_options])
- @uploader.version *version_args do
+ passing_options[:root_uploader].version *version_args do
Injector.new(self, passing_options, &block)
end
end
def method_missing *args, &block
\ No newline at end of file