Module: IdsOfAllDirectDependencies

Includes:
SymbolsOfAllDirectDependencies
Included in:
IdsOfAllDependencies
Defined in:
lib/ids_of_all_dependencies.rb

Instance Method Summary collapse

Methods included from SymbolsOfAllDirectDependencies

#symbols_of_all_direct_dependencies

Instance Method Details

#ids_of_all_direct_dependenciesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ids_of_all_dependencies.rb', line 16

def ids_of_all_direct_dependencies
  result = IdHash.new

  self.class.reflect_on_all_associations.map do |association|
    next if association.macro == :belongs_to

    symbol = association.klass.name.underscore.to_sym
    self.send(association.name).map do |associated_object|
      result.add(symbol, associated_object.id)
    end
  end

  result
end