Sha256: 55a0618e5683d30e93230b85339e0e3b20893dad60e88755919ce27c33c80ed3

Contents?: true

Size: 433 Bytes

Versions: 4

Compression:

Stored size: 433 Bytes

Contents

require 'id_hash'

module IdsOfAllDirectDependencies
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dependency-trees-0.0.8 lib/ids_of_all_direct_dependencies.rb
dependency-trees-0.0.7 lib/ids_of_all_direct_dependencies.rb
dependency-trees-0.0.6 lib/ids_of_all_direct_dependencies.rb
dependency-trees-0.0.5 lib/ids_of_all_direct_dependencies.rb