Method: FileColumn::MagickExtension.process_options

Defined in:
lib/magick_file_column.rb

.process_options(options, create_name = true) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/magick_file_column.rb', line 241

def self.process_options(options,create_name=true)
  case options
  when String then options = {:size => options}
  when Proc, Symbol then options = {:transformation => options }
  end
  if options[:geometry]
    options[:size] = options.delete(:geometry)
  end
  options[:image_required] = true unless options.key?(:image_required)
  if options[:name].nil? and create_name
    if create_name == true
      hash = 0
      for key in [:size, :crop]
        hash = hash ^ options[key].hash if options[key]
      end
      options[:name] = hash.abs.to_s(36)
    else
      options[:name] = create_name
    end
  end
  options
end