Module: IdsOfAllDirectDependencies

Defined in:
lib/ids_of_all_direct_dependencies.rb

Instance Method Summary collapse

Instance Method Details

#ids_of_all_direct_dependenciesObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ids_of_all_direct_dependencies.rb', line 4

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