module Shrine::Plugins::RemoveAttachment::AttacherMethods
Public Instance Methods
remove()
click to toggle source
# File lib/shrine/plugins/remove_attachment.rb, line 29 def remove @remove end
remove=(value)
click to toggle source
We remove the attachment if the value evaluates to true.
# File lib/shrine/plugins/remove_attachment.rb, line 23 def remove=(value) @remove = value change(nil) if remove? end
Private Instance Methods
change?(file)
click to toggle source
Don’t override previously removed attachment that wasn’t yet deleted.
Calls superclass method
# File lib/shrine/plugins/remove_attachment.rb, line 36 def change?(file) super && !(changed? && remove?) end
remove?()
click to toggle source
Rails sends “0” or “false” if the checkbox hasn’t been ticked.
# File lib/shrine/plugins/remove_attachment.rb, line 41 def remove? return remove if [true, false].include?(remove) remove && remove != "" && remove !~ /\A(0|false)\z/ end