Class: CarrierWave::Mount::Mounter
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
-
#column ⇒ Object
readonly
:nodoc:.
-
#integrity_error ⇒ Object
Returns the value of attribute integrity_error.
-
#options ⇒ Object
readonly
:nodoc:.
-
#processing_error ⇒ Object
Returns the value of attribute processing_error.
-
#record ⇒ Object
readonly
:nodoc:.
-
#remove ⇒ Object
Returns the value of attribute remove.
-
#uploader ⇒ Object
Returns the value of attribute uploader.
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #cache(new_file) ⇒ Object
- #cache_name ⇒ Object
- #cache_name=(cache_name) ⇒ Object
- #identifier ⇒ Object
-
#initialize(record, column, options = {}) ⇒ Mounter
constructor
A new instance of Mounter.
- #remove! ⇒ Object
- #remove? ⇒ Boolean
- #store! ⇒ Object
- #url(*args) ⇒ Object
- #write_identifier ⇒ Object
Constructor Details
#initialize(record, column, options = {}) ⇒ Mounter
Returns a new instance of Mounter.
249 250 251 252 253 |
# File 'lib/carrierwave/mount.rb', line 249 def initialize(record, column, ={}) @record = record @column = column @options = record.class.[column] end |
Instance Attribute Details
#column ⇒ Object (readonly)
:nodoc:
245 246 247 |
# File 'lib/carrierwave/mount.rb', line 245 def column @column end |
#integrity_error ⇒ Object
Returns the value of attribute integrity_error.
247 248 249 |
# File 'lib/carrierwave/mount.rb', line 247 def integrity_error @integrity_error end |
#options ⇒ Object (readonly)
:nodoc:
245 246 247 |
# File 'lib/carrierwave/mount.rb', line 245 def @options end |
#processing_error ⇒ Object
Returns the value of attribute processing_error.
247 248 249 |
# File 'lib/carrierwave/mount.rb', line 247 def processing_error @processing_error end |
#record ⇒ Object (readonly)
:nodoc:
245 246 247 |
# File 'lib/carrierwave/mount.rb', line 245 def record @record end |
#remove ⇒ Object
Returns the value of attribute remove.
247 248 249 |
# File 'lib/carrierwave/mount.rb', line 247 def remove @remove end |
#uploader ⇒ Object
Returns the value of attribute uploader.
247 248 249 |
# File 'lib/carrierwave/mount.rb', line 247 def uploader @uploader end |
Instance Method Details
#blank? ⇒ Boolean
311 312 313 |
# File 'lib/carrierwave/mount.rb', line 311 def blank? uploader.blank? end |
#cache(new_file) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/carrierwave/mount.rb', line 276 def cache(new_file) uploader.cache!(new_file) self.integrity_error = nil self.processing_error = nil rescue CarrierWave::IntegrityError => e self.integrity_error = e raise e unless [:ignore_integrity_errors] rescue CarrierWave::ProcessingError => e self.processing_error = e raise e unless [:ignore_processing_errors] end |
#cache_name ⇒ Object
288 289 290 |
# File 'lib/carrierwave/mount.rb', line 288 def cache_name uploader.cache_name end |
#cache_name=(cache_name) ⇒ Object
292 293 294 295 |
# File 'lib/carrierwave/mount.rb', line 292 def cache_name=(cache_name) uploader.retrieve_from_cache!(cache_name) unless uploader.cached? rescue CarrierWave::InvalidParameter end |
#identifier ⇒ Object
263 264 265 |
# File 'lib/carrierwave/mount.rb', line 263 def identifier record.read_uploader(serialization_column) end |
#remove! ⇒ Object
319 320 321 |
# File 'lib/carrierwave/mount.rb', line 319 def remove! uploader.remove! end |
#remove? ⇒ Boolean
315 316 317 |
# File 'lib/carrierwave/mount.rb', line 315 def remove? !remove.blank? and remove !~ /\A0|false$\z/ end |
#store! ⇒ Object
297 298 299 300 301 302 303 304 305 |
# File 'lib/carrierwave/mount.rb', line 297 def store! unless uploader.blank? if remove? uploader.remove! else uploader.store! end end end |
#url(*args) ⇒ Object
307 308 309 |
# File 'lib/carrierwave/mount.rb', line 307 def url(*args) uploader.url(*args) end |
#write_identifier ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/carrierwave/mount.rb', line 255 def write_identifier if remove? record.write_uploader(serialization_column, '') elsif not uploader.identifier.blank? record.write_uploader(serialization_column, uploader.identifier) end end |