Sha256: 723a158fa1e0a208bae0cf27ddc047941f796d9da6c5499acb8882ad200aabcf

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'active_support'
require 'carrierwave'
require "carrierwave/processor/version"
require "carrierwave/processor/injector"
require 'carrierwave/processor/uploader_dsl'

module CarrierWave
  module Processor

    class ProcessorNotFoundError < ::StandardError
    end

    class << self
      attr_accessor :processors
    end

    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

    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

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

Object.send :include, CarrierWave::Processor::Dsl
CarrierWave::Uploader::Base.extend CarrierWave::Processor::UploaderDsl

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
carrierwave-processor-1.0.3 lib/carrierwave/processor.rb
carrierwave-processor-1.0.2 lib/carrierwave/processor.rb