Class: ActiveShrine::Attached::Changes::DetachMany

Inherits:
Object
  • Object
show all
Defined in:
lib/active_shrine/attached/changes/detach_many.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, record, attachments) ⇒ DetachMany

Returns a new instance of DetachMany.



9
10
11
12
13
# File 'lib/active_shrine/attached/changes/detach_many.rb', line 9

def initialize(name, record, attachments)
  @name = name
  @record = record
  @attachments = attachments
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



7
8
9
# File 'lib/active_shrine/attached/changes/detach_many.rb', line 7

def attachments
  @attachments
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/active_shrine/attached/changes/detach_many.rb', line 7

def name
  @name
end

#recordObject (readonly)

Returns the value of attribute record.



7
8
9
# File 'lib/active_shrine/attached/changes/detach_many.rb', line 7

def record
  @record
end

Instance Method Details

#detachObject



15
16
17
18
19
20
# File 'lib/active_shrine/attached/changes/detach_many.rb', line 15

def detach
  return unless attachments.any?

  attachments.delete_all if attachments.respond_to?(:delete_all)
  record.shrine_attachment_changes.delete(name)
end