Class: ActiveShrine::Attached::Changes::DetachOne

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, record, attachment) ⇒ DetachOne

Returns a new instance of DetachOne.



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

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

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



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

def attachment
  @attachment
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/active_shrine/attached/changes/detach_one.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_one.rb', line 7

def record
  @record
end

Instance Method Details

#detachObject



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

def detach
  return unless attachment.present?

  attachment.delete
  reset
end