Class: Uploadcare::Rails::Configuration
- Inherits:
-
Object
- Object
- Uploadcare::Rails::Configuration
- Includes:
- Singleton
- Defined in:
- lib/uploadcare/rails/configuration.rb
Overview
A class for storing config parameters
Constant Summary collapse
- CONFIG_GLOBAL_PARAMS =
Global gem configuration parameters
%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 ].freeze
- FILE_UPLOADER_PARAMS =
File Uploader configuration parameters See uploadcare.com/docs/file-uploader/configuration/ for details
These parameters map to uc-config attributes:
Ruby snake_case => HTML kebab-case Example: img_only => img-only, source_list => source-list %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
- WIDGET_PARAMS =
Legacy widget parameters (deprecated, kept for backward compatibility)
%w[ public_key images_only preview_step crop image_shrink clearable tabs input_accept_types preferred_types system_dialog multipart_min_size preview_proxy cdn_base do_not_store audio_bits_per_second video_preferred_mime_types video_bits_per_second camera_mirror_default live manual_start locale locale_translations locale_pluralize ].freeze
Instance Method Summary collapse
-
#uploader_config_attributes ⇒ Object
Returns configuration attributes for the uc-config element All parameters are converted from snake_case to kebab-case.
-
#uploader_parameters ⇒ Object
deprecated
Deprecated.
Use uploader_config_attributes instead
-
#widget ⇒ Object
deprecated
Deprecated.
Use uploader_config_attributes instead
Instance Method Details
#uploader_config_attributes ⇒ Object
Returns configuration attributes for the uc-config element All parameters are converted from snake_case to kebab-case
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/uploadcare/rails/configuration.rb', line 68 def uploader_config_attributes attrs = {} FILE_UPLOADER_PARAMS.each do |param_name| param_value = instance_variable_get("@#{param_name}") next if param_value.nil? # Convert snake_case to kebab-case for HTML attributes # Special case: public_key => pubkey 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 |
#uploader_parameters ⇒ Object
Deprecated.
Use uploader_config_attributes instead
Legacy method for backward compatibility with old widget
91 92 93 94 95 96 97 98 99 |
# File 'lib/uploadcare/rails/configuration.rb', line 91 def uploader_parameters WIDGET_PARAMS.map do |param_name| param_value = instance_variable_get("@#{param_name}") next if param_value.nil? param_value = handle_param_value(param_value) "UPLOADCARE_#{param_name.upcase} = #{param_value};" end.compact.join("\n") end |
#widget ⇒ Object
Deprecated.
Use uploader_config_attributes instead
102 103 104 105 106 |
# File 'lib/uploadcare/rails/configuration.rb', line 102 def Struct .new(*WIDGET_PARAMS.map(&:to_sym)) .new(*WIDGET_PARAMS.map { |param| public_send(param) }) end |