Sha256: b581de79c3ac4f5360509ca3a8a1e236cfd863fac1c46bddeea624b8d62978fd

Contents?: true

Size: 1.07 KB

Versions: 24

Compression:

Stored size: 1.07 KB

Contents

require_relative "type"

module Foobara
  module Manifest
    class Model < Type
      self.category_symbol = :type

      alias model_manifest relevant_manifest

      def attributes_type
        Attributes.new(root_manifest, [*path, :attributes_type])
      end

      def attribute_names
        attributes_type.attribute_names
      end

      def full_model_name
        scoped_full_name
      end

      # TODO: rename
      def has_associations?(type = attributes_type)
        case type
        when Entity
          true
        when Model
          has_associations?(type.attributes_type)
        when Attributes
          type.attribute_declarations.values.any? do |attribute_declaration|
            has_associations?(attribute_declaration)
          end
        when Array
          has_associations?(type.element_type)
        when TypeDeclaration
          has_associations?(type.to_type)
        when Type
          type.entity?
        else
          # :nocov:
          raise "not sure how to proceed with #{type}"
          # :nocov:
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.25 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.24 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.23 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.22 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.21 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.20 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.19 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.18 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.17 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.16 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.15 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.14 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.13 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.12 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.11 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.10 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.9 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.8 projects/manifest/src/foobara/manifest/model.rb
foobara-0.0.7 projects/manifest/src/foobara/manifest/model.rb