Module: Polyamorous::JoinDependencyExtensions::ClassMethods

Defined in:
lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb

Instance Method Summary collapse

Instance Method Details

#walk_tree(associations, hash) ⇒ Object

Prepended before ActiveRecord::Associations::JoinDependency#walk_tree



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb', line 71

def walk_tree(associations, hash)
  case associations
  when TreeNode
    associations.add_to_tree(hash)
  when Hash
    associations.each do |k, v|
      cache =
        if TreeNode === k
          k.add_to_tree(hash)
        else
          hash[k] ||= {}
        end
      walk_tree(v, cache)
    end
  else
    super(associations, hash)
  end
end