Module: Shrine::Plugins::MigrationHelpers::AttacherMethods

Defined in:
lib/shrine/plugins/migration_helpers.rb

Instance Method Summary collapse

Instance Method Details

#cached?Boolean

Returns true if the attachment is present and is uploaded by the temporary storage.

Returns:

  • (Boolean)


56
57
58
# File 'lib/shrine/plugins/migration_helpers.rb', line 56

def cached?
  get && cache.uploaded?(get)
end

#stored?Boolean

Returns true if the attachment is present and is uploaded by the permanent storage.

Returns:

  • (Boolean)


62
63
64
# File 'lib/shrine/plugins/migration_helpers.rb', line 62

def stored?
  get && store.uploaded?(get)
end

#update_stored(&block) ⇒ Object

Updates the attachment with the result of the block. It will get called only if the attachment exists and is stored.



48
49
50
51
52
# File 'lib/shrine/plugins/migration_helpers.rb', line 48

def update_stored(&block)
  return if get.nil? || cache.uploaded?(get)
  new_attachment = block.call(get)
  swap(new_attachment)
end