Class: CarrierWave::Mount::Mounter
- Inherits:
-
Object
- Object
- CarrierWave::Mount::Mounter
- Defined in:
- lib/carrierwave/mount.rb
Overview
this is an internal class, used by CarrierWave::Mount so that we don't pollute the model with a lot of methods.
Instance Attribute Summary (collapse)
-
- (Object) column
readonly
:nodoc:.
-
- (Object) integrity_error
readonly
:nodoc:.
-
- (Object) processing_error
readonly
:nodoc:.
-
- (Object) record
readonly
:nodoc:.
-
- (Object) remote_url
:nodoc:.
-
- (Object) remove
Returns the value of attribute remove.
Instance Method Summary (collapse)
- - (Boolean) blank?
- - (Object) cache(new_file)
- - (Object) cache_name
- - (Object) cache_name=(cache_name)
- - (Object) identifier
-
- (Mounter) initialize(record, column, options = {})
constructor
A new instance of Mounter.
- - (Object) remove!
- - (Boolean) remove?
- - (Object) store!
- - (Object) uploader
- - (Object) url(*args)
- - (Object) write_identifier
Constructor Details
- (Mounter) initialize(record, column, options = {})
A new instance of Mounter
263 264 265 266 267 |
# File 'lib/carrierwave/mount.rb', line 263 def initialize(record, column, ={}) @record = record @column = column @options = record.class.[column] end |
Instance Attribute Details
- (Object) column (readonly)
:nodoc:
260 261 262 |
# File 'lib/carrierwave/mount.rb', line 260 def column @column end |
- (Object) integrity_error (readonly)
:nodoc:
260 261 262 |
# File 'lib/carrierwave/mount.rb', line 260 def integrity_error @integrity_error end |
- (Object) processing_error (readonly)
:nodoc:
260 261 262 |
# File 'lib/carrierwave/mount.rb', line 260 def processing_error @processing_error end |
- (Object) record (readonly)
:nodoc:
260 261 262 |
# File 'lib/carrierwave/mount.rb', line 260 def record @record end |
- (Object) remote_url
:nodoc:
260 261 262 |
# File 'lib/carrierwave/mount.rb', line 260 def remote_url @remote_url end |
- (Object) remove
Returns the value of attribute remove
261 262 263 |
# File 'lib/carrierwave/mount.rb', line 261 def remove @remove end |
Instance Method Details
- (Boolean) blank?
332 333 334 |
# File 'lib/carrierwave/mount.rb', line 332 def blank? uploader.blank? end |
- (Object) cache(new_file)
290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/carrierwave/mount.rb', line 290 def cache(new_file) uploader.cache!(new_file) @integrity_error = nil @processing_error = nil rescue CarrierWave::IntegrityError => e @integrity_error = e raise e unless option(:ignore_integrity_errors) rescue CarrierWave::ProcessingError => e @processing_error = e raise e unless option(:ignore_processing_errors) end |
- (Object) cache_name
302 303 304 |
# File 'lib/carrierwave/mount.rb', line 302 def cache_name uploader.cache_name end |
- (Object) cache_name=(cache_name)
306 307 308 309 |
# File 'lib/carrierwave/mount.rb', line 306 def cache_name=(cache_name) uploader.retrieve_from_cache!(cache_name) unless uploader.cached? rescue CarrierWave::InvalidParameter end |
- (Object) identifier
277 278 279 |
# File 'lib/carrierwave/mount.rb', line 277 def identifier record.read_uploader(serialization_column) end |
- (Object) remove!
340 341 342 |
# File 'lib/carrierwave/mount.rb', line 340 def remove! uploader.remove! end |
- (Boolean) remove?
336 337 338 |
# File 'lib/carrierwave/mount.rb', line 336 def remove? !remove.blank? and remove !~ /\A0|false$\z/ end |
- (Object) store!
318 319 320 321 322 323 324 325 326 |
# File 'lib/carrierwave/mount.rb', line 318 def store! unless uploader.blank? if remove? uploader.remove! else uploader.store! end end end |
- (Object) uploader
281 282 283 284 285 286 287 288 |
# File 'lib/carrierwave/mount.rb', line 281 def uploader @uploader ||= record.class.uploaders[column].new(record, column) if @uploader.blank? and not identifier.blank? @uploader.retrieve_from_store!(identifier) end return @uploader end |
- (Object) url(*args)
328 329 330 |
# File 'lib/carrierwave/mount.rb', line 328 def url(*args) uploader.url(*args) end |
- (Object) write_identifier
269 270 271 272 273 274 275 |
# File 'lib/carrierwave/mount.rb', line 269 def write_identifier if remove? record.write_uploader(serialization_column, '') elsif not uploader.identifier.blank? record.write_uploader(serialization_column, uploader.identifier) end end |