Class: Uploadcare::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/uploadcare/rails/configuration.rb

Constant Summary collapse

RAILS_PARAMS =
%w[
  public_key secret_key
  cache_files cache_expires_in cache_namespace cdn_hostname
  store_files_after_save store_files_async
  delete_files_after_destroy delete_files_async
  job_queue
].freeze
FILE_UPLOADER_PARAMS =
%w[
  public_key
  multiple
  img_only
  accept
  external_sources_preferred_types
  store
  camera_mirror
  source_list
  max_local_file_size_bytes
  cdn_cname
  base_url
  social_base_url
  secure_signature
  secure_expire
  secure_delivery_proxy
  retry_throttled_request_max_count
  multipart_min_file_size
  multipart_chunk_size
  max_concurrent_requests
  multipart_max_attempts
  check_for_url_duplicates
  save_url_for_recurrent_uploads
  group_output
  locale
  metadata
  remove_copyright
  crop_preset
  image_shrink
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(source = nil) ⇒ Configuration

Returns a new instance of Configuration.



47
48
49
50
51
52
53
54
55
# File 'lib/uploadcare/rails/configuration.rb', line 47

def initialize(source = nil)
  @cache_files = false
  @cache_expires_in = 300
  @store_files_after_save = false
  @store_files_async = false
  @delete_files_after_destroy = false
  @delete_files_async = false
  apply(source)
end

Instance Method Details

#uploader_config_attributesObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/uploadcare/rails/configuration.rb', line 57

def uploader_config_attributes
  attrs = {}

  FILE_UPLOADER_PARAMS.each do |param_name|
    param_value = instance_variable_get("@#{param_name}")
    next if param_value.nil?

    attr_name = if param_name == "public_key"
                  :pubkey
    else
                  param_name.tr("_", "-").to_sym
    end

    attrs[attr_name] = format_config_value(param_value)
  end

  attrs
end