Module: CarrierWave::Processor

Defined in:
lib/carrierwave/processor.rb,
lib/carrierwave/processor/dsl.rb,
lib/carrierwave/processor/version.rb,
lib/carrierwave/processor/injector.rb,
lib/carrierwave/processor/backend/base.rb,
lib/carrierwave/processor/uploader_dsl.rb,
lib/carrierwave/processor/configuration.rb

Defined Under Namespace

Modules: Backend, Dsl, UploaderDsl Classes: BackendNotFound, BackendNotInitializedError, Configuration, Injector, ProcessorNotFoundError

Constant Summary collapse

VERSION =
"1.1.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



23
24
25
# File 'lib/carrierwave/processor.rb', line 23

def self.configuration
  @configuration ||= Configuration.new
end

.processorsObject

Returns the value of attribute processors.



19
20
21
# File 'lib/carrierwave/processor.rb', line 19

def processors
  @processors
end

Class Method Details

.arguments_merge(*args) ⇒ Object



56
57
58
59
60
61
# File 'lib/carrierwave/processor.rb', line 56

def self.arguments_merge *args
  args.inject({}) do |hash, arg|
    arg = { arg => [] } unless arg.is_a?(Hash)
    hash.merge!(arg)
  end
end

.conditions_merge(*args) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/carrierwave/processor.rb', line 35

def self.conditions_merge *args
  args.flatten!
  args.compact!
  return nil if args.empty?
  return args.first if args.length == 1
  self.merge_multiple_conditions *args
end

.configure(options = {}) {|c| ... } ⇒ Object

Yields:

  • (c)


27
28
29
30
31
32
33
# File 'lib/carrierwave/processor.rb', line 27

def self.configure options={}, &block
  c = configuration
  options.each do |k, v|
    c.send "#{k}=", v
  end
  yield c
end

.merge_multiple_conditions(*args) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/carrierwave/processor.rb', line 43

def self.merge_multiple_conditions *args
  lambda do |uploader, options|
    args.inject(true) do |accum, condition|
      break false unless accum
      condition_result = if condition.respond_to?(:call)
        accum && condition.call(self, options)
      else
        accum && uploader.send(condition, options[:file])
      end
    end
  end
end

.rootObject



11
12
13
# File 'lib/carrierwave/processor.rb', line 11

def self.root
  Pathname.new(File.expand_path '../..', __FILE__)
end