Module: CarrierWave::Uploader::Configuration::ClassMethods
- Defined in:
- lib/carrierwave/uploader/configuration.rb
Instance Method Summary collapse
- #add_config(name) ⇒ Object
- #configure {|_self| ... } ⇒ Object
-
#reset_config ⇒ Object
sets configuration back to default.
-
#storage(storage = nil) ⇒ Object
(also: #storage=)
Sets the storage engine to be used when storing files with this uploader.
Instance Method Details
#add_config(name) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/carrierwave/uploader/configuration.rb', line 94 def add_config(name) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def self.#{name}(value=nil) @#{name} = value if value return @#{name} if self.object_id == #{self.object_id} || defined?(@#{name}) name = superclass.#{name} return nil if name.nil? && !instance_variable_defined?("@#{name}") @#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name end def self.#{name}=(value) @#{name} = value end def #{name} self.class.#{name} end RUBY end |
#configure {|_self| ... } ⇒ Object
114 115 116 |
# File 'lib/carrierwave/uploader/configuration.rb', line 114 def configure yield self end |
#reset_config ⇒ Object
sets configuration back to default
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/carrierwave/uploader/configuration.rb', line 121 def reset_config configure do |config| config. = 0644 config.storage_engines = { :file => "CarrierWave::Storage::File", :fog => "CarrierWave::Storage::Fog", :s3 => "CarrierWave::Storage::S3", :grid_fs => "CarrierWave::Storage::GridFS", :right_s3 => "CarrierWave::Storage::RightS3", :cloud_files => "CarrierWave::Storage::CloudFiles" } config.storage = :file config.s3_headers = {} config.s3_access_policy = :public_read config.s3_region = 'us-east-1' config.s3_authentication_timeout = 600 config.grid_fs_database = 'carrierwave' config.grid_fs_host = 'localhost' config.grid_fs_port = 27017 config.fog_attributes = {} config.fog_credentials = {} config.fog_public = true config.fog_authenticated_url_expiration = 600 config.store_dir = 'uploads' config.cache_dir = 'uploads/tmp' config.delete_tmp_file_after_storage = true config.remove_previously_stored_files_after_update = true config.ignore_integrity_errors = true config.ignore_processing_errors = true config.validate_integrity = true config.validate_processing = true config.root = CarrierWave.root config.enable_processing = true config.ensure_multipart_form = true end end |
#storage(storage = nil) ⇒ Object Also known as: storage=
Sets the storage engine to be used when storing files with this uploader. Can be any class that implements a #store!(CarrierWave::SanitizedFile) and a #retrieve! method. See lib/carrierwave/storage/file.rb for an example. Storage engines should be added to CarrierWave::Uploader::Base.storage_engines so they can be referred to by a symbol, which should be more convenient
If no argument is given, it will simply return the currently used storage engine.
Parameters
- storage (Symbol, Class)
-
The storage engine to use for this uploader
Returns
- Class
-
the storage engine to be used with this uploader
Examples
storage :file
storage CarrierWave::Storage::File
storage MyCustomStorageEngine
86 87 88 89 90 91 |
# File 'lib/carrierwave/uploader/configuration.rb', line 86 def storage(storage = nil) if storage self._storage = storage.is_a?(Symbol) ? eval(storage_engines[storage]) : storage end _storage end |