Class: CrudComponents::Admin::Dependents
- Inherits:
-
Object
- Object
- CrudComponents::Admin::Dependents
- Defined in:
- lib/crud_components/admin/dependents.rb
Overview
What else goes when a record is destroyed: the associations that declare a
dependent: behaviour, counted, plus the ones that would block it.
Defined Under Namespace
Constant Summary collapse
- DESTROYING =
%i[destroy destroy_async delete_all].freeze
- BLOCKING =
%i[restrict_with_error restrict_with_exception].freeze
- PREVIEW =
How many of an item's records the confirmation page names.
10
Class Method Summary collapse
Instance Method Summary collapse
-
#blockers ⇒ Object
Anything that blocks the delete outright.
-
#initialize(record) ⇒ Dependents
constructor
A new instance of Dependents.
- #items ⇒ Object
Constructor Details
#initialize(record) ⇒ Dependents
Returns a new instance of Dependents.
51 52 53 |
# File 'lib/crud_components/admin/dependents.rb', line 51 def initialize(record) @record = record end |
Class Method Details
.for(record) ⇒ Object
49 |
# File 'lib/crud_components/admin/dependents.rb', line 49 def self.for(record) = new(record).items |
Instance Method Details
#blockers ⇒ Object
Anything that blocks the delete outright.
60 |
# File 'lib/crud_components/admin/dependents.rb', line 60 def blockers = items.select(&:blocks?) |
#items ⇒ Object
55 56 57 |
# File 'lib/crud_components/admin/dependents.rb', line 55 def items @items ||= (association_items + ).reject { |item| item.count.zero? } end |