Method: Conflow::Redis::Model#destroy!

Defined in:
lib/conflow/redis/model.rb

#destroy!(execute: true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removes this and all related models.

Parameters:

  • execute (Boolean) (defaults to: true)

    if false, only returns keys that would be removed



22
23
24
25
26
27
28
29
# File 'lib/conflow/redis/model.rb', line 22

def destroy!(execute: true)
  keys = self.class.fields.map { |name| send(name).key }
  related_keys = self.class.relations.map(&method(:collect_relation_keys))

  (keys + related_keys).flatten.tap do |key_list|
    command :del, [key_list] if execute && key_list.any?
  end
end