Class: Injector
- Inherits:
-
Module
show all
- Defined in:
- lib/carrierwave/processor/injector.rb
Instance Method Summary
collapse
Constructor Details
#initialize(uploader, opts = {}, &block) ⇒ Injector
PLUGIN_OPTIONS = [:outer_version, :root_uploader]
8
9
10
11
12
13
14
15
|
# File 'lib/carrierwave/processor/injector.rb', line 8
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
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
43
44
45
|
# File 'lib/carrierwave/processor/injector.rb', line 43
def method_missing *args, &block
@uploader.send *args, &block
end
|
Instance Method Details
#delay(*args, &block) ⇒ Object
47
48
|
# File 'lib/carrierwave/processor/injector.rb', line 47
def delay *args, &block
end
|
#process(*args, &block) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/carrierwave/processor/injector.rb', line 17
def process *args, &block
processed_options = ::CarrierWave::Processor.arguments_merge *args
unless @outer_version
new_if = ::CarrierWave::Processor.conditions_merge(@options[:if], processed_options[:if])
processed_options[:if] = new_if if new_if
end
@uploader.process processed_options, &block
end
|
#version(*args, &block) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/carrierwave/processor/injector.rb', line 26
def version *args, &block
options = args. || {}
version_options = @options.merge options
ifs_array = [@options[:if], options[:if]]
new_if = ::CarrierWave::Processor.conditions_merge *ifs_array
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])
passing_options[:root_uploader].version *version_args do
Injector.new(self, passing_options, &block)
end
end
|