Sha256: b51ca5a224c1ee47fd6f7ac4077786674df9a72f7251ee81e1f6a0eddaea9204

Contents?: true

Size: 381 Bytes

Versions: 1

Compression:

Stored size: 381 Bytes

Contents

class CategoryDestroyer
  attr_reader :category

  def initialize(category:)
    @category = category
  end

  def destroy
    raise LastObjectInCollectionDeletionError if category.last_for_project?
    raise ObjectAssociatedToDependents        if category.have_dependents?

    category.destroy!
  end

  def self.destroy(category:)
    new(category: category).destroy
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
self_systeem-0.1.0 test/dummy_app/app/services/category_destroyer.rb