Module: Undeletable::ClassMethods

Defined in:
lib/undeletable.rb

Instance Method Summary collapse

Instance Method Details

#delete(id_or_array) ⇒ Object

Raises:

  • (ActiveRecord::ReadOnlyRecord)


22
23
24
25
# File 'lib/undeletable.rb', line 22

def delete(id_or_array)
  raise ActiveRecord::ReadOnlyRecord.new("#{self} is undeletable") if raise_on_delete?
  logger.debug("will not #{self}.delete #{id_or_array.inspect}", e) if Undeletable.debug
end

#delete_all(conditions = nil) ⇒ Object

Raises:

  • (ActiveRecord::ReadOnlyRecord)


27
28
29
30
# File 'lib/undeletable.rb', line 27

def delete_all(conditions = nil)
  raise ActiveRecord::ReadOnlyRecord.new("#{self} is undeletable") if raise_on_delete?
  logger.debug("will not #{self}.delete_all", e) if Undeletable.debug
end

#raise_on_delete?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/undeletable.rb', line 18

def raise_on_delete?
  self.raise_on_delete
end

#undeletable?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/undeletable.rb', line 14

def undeletable?
  true
end