Sha256: 88561f2fc9a7153d21262dfe3f58914c39de260b1c03efb7e6ffad870c9b6ab1

Contents?: true

Size: 1.48 KB

Versions: 20

Compression:

Stored size: 1.48 KB

Contents

module Foobara
  class Entity < Model
    module Concerns
      module Reflection
        include Concern

        module ClassMethods
          def depends_on
            associations.values.map(&:target_class).uniq
          end

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

            types.map(&:target_class).uniq
          end

          def foobara_manifest(to_include:)
            associations = self.associations.map do |(path, type)|
              entity_class = type.target_class
              entity_name = entity_class.full_entity_name

              [path, entity_name]
            end.sort.to_h

            deep_associations = self.deep_associations.map do |(path, type)|
              entity_class = type.target_class
              entity_name = entity_class.full_entity_name

              [path, entity_name]
            end.sort.to_h

            super.merge(
              Util.remove_blank(
                depends_on: depends_on.map(&:full_entity_name),
                deep_depends_on: deep_depends_on.map(&:full_entity_name),
                associations:,
                deep_associations:,
                entity_name:,
                primary_key_attribute:,
                primary_key_type: attributes_type.declaration_data[:element_type_declarations][primary_key_attribute]
              )
            )
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foobara-0.0.20 projects/entity/src/concerns/reflection.rb
foobara-0.0.19 projects/entity/src/concerns/reflection.rb
foobara-0.0.18 projects/entity/src/concerns/reflection.rb
foobara-0.0.17 projects/entity/src/concerns/reflection.rb
foobara-0.0.16 projects/entity/src/concerns/reflection.rb
foobara-0.0.15 projects/entity/src/concerns/reflection.rb
foobara-0.0.14 projects/entity/src/concerns/reflection.rb
foobara-0.0.13 projects/entity/src/concerns/reflection.rb
foobara-0.0.12 projects/entity/src/concerns/reflection.rb
foobara-0.0.11 projects/entity/src/concerns/reflection.rb
foobara-0.0.10 projects/entity/src/concerns/reflection.rb
foobara-0.0.9 projects/entity/src/concerns/reflection.rb
foobara-0.0.8 projects/entity/src/concerns/reflection.rb
foobara-0.0.7 projects/entity/src/concerns/reflection.rb
foobara-0.0.6 projects/entity/src/concerns/reflection.rb
foobara-0.0.5 projects/entity/src/concerns/reflection.rb
foobara-0.0.4 projects/entity/src/concerns/reflection.rb
foobara-0.0.3 projects/entity/src/concerns/reflection.rb
foobara-0.0.2 projects/entity/src/concerns/reflection.rb
foobara-0.0.1 projects/entity/src/concerns/reflection.rb