Module: Foobara::DetachedEntity::Concerns::Reflection::ClassMethods

Defined in:
foobara-0.0.110/projects/detached_entity/src/concerns/reflection.rb

Instance Method Summary collapse

Instance Method Details

#foobara_deep_depends_onObject



12
13
14
15
16
17
18
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/reflection.rb', line 12

def foobara_deep_depends_on
  types = foobara_deep_associations.sort_by do |path, _type|
    [DataPath.new(path).path.size, path]
  end.map(&:last)

  types.map(&:target_class).uniq
end

#foobara_depends_onObject



8
9
10
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/reflection.rb', line 8

def foobara_depends_on
  foobara_associations.values.map(&:target_class).uniq
end

#foobara_manifestObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/reflection.rb', line 20

def foobara_manifest
  associations = foobara_associations.map do |(path, type)|
    entity_class = type.target_class
    entity_name = entity_class.foobara_type.scoped_full_name

    [path, entity_name]
  end.sort.to_h

  deep_associations = foobara_deep_associations.map do |(path, type)|
    entity_class = type.target_class
    entity_name = entity_class.foobara_type.scoped_full_name

    [path, entity_name]
  end.sort.to_h

  base_manifest = superclass.respond_to?(:foobara_manifest) ? super : {}

  base_manifest.merge(
    Util.remove_blank(
      depends_on: foobara_depends_on.map(&:full_entity_name),
      deep_depends_on: foobara_deep_depends_on.map(&:full_entity_name),
      associations:,
      deep_associations:,
      entity_name: foobara_model_name,
      primary_key_attribute: foobara_primary_key_attribute,
      primary_key_type:
        foobara_attributes_type.declaration_data[:element_type_declarations][foobara_primary_key_attribute]
    )
  )
end