Class: CrudComponents::Admin::Dependents::Selection

Inherits:
Object
  • Object
show all
Defined in:
lib/crud_components/admin/dependents.rb

Overview

The same overview for several records at once: one item per association, counts summed, names taken across the selection.

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ Selection

Returns a new instance of Selection.



31
# File 'lib/crud_components/admin/dependents.rb', line 31

def initialize(records) = @records = records

Instance Method Details

#blockersObject



38
# File 'lib/crud_components/admin/dependents.rb', line 38

def blockers = items.select(&:blocks?)

#itemsObject



33
34
35
36
# File 'lib/crud_components/admin/dependents.rb', line 33

def items
  @items ||= @records.flat_map { |record| Dependents.new(record).items }
                     .group_by(&:name).map { |name, items| merged(name, items) }
end