Method: ViewModel::ActiveRecord.dependent_viewmodels

Defined in:
lib/view_model/active_record.rb

.dependent_viewmodels(seen = Set.new, include_referenced: true, include_external: true) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/view_model/active_record.rb', line 224

def dependent_viewmodels(seen = Set.new, include_referenced: true, include_external: true)
  return if seen.include?(self)

  seen << self

  _members.each_value do |data|
    next unless data.is_a?(AssociationData)
    next unless include_referenced || !data.referenced?
    next unless include_external   || !data.external?

    data.viewmodel_classes.each do |vm|
      vm.dependent_viewmodels(seen, include_referenced: include_referenced, include_external: include_external)
    end
  end

  seen
end