Class: BulletmarkRepairer::LoadedAssociations

Inherits:
Object
  • Object
show all
Defined in:
lib/bulletmark_repairer/loaded_associations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#associationsObject (readonly)

Returns the value of attribute associations.



5
6
7
# File 'lib/bulletmark_repairer/loaded_associations.rb', line 5

def associations
  @associations
end

Instance Method Details

#key(target_klass_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bulletmark_repairer/loaded_associations.rb', line 7

def key(target_klass_name)
  key = target_klass_name.underscore

  result = []
  @associations.each do |_base_klass_name, all_associations|
    all_associations.each do |_key, associations|
      # TODO: reccurent check
      associations.each do |values|
        values.flatten.each do |value|
          result.append search_key(key, value)
        end
      end
    end
  end
  result = result.flatten.compact.uniq.presence
  build_keys(result)
end