Sha256: fc8ea8e34d09837651cb183436879254bdc18b443441f717d65888ee6e280f0a

Contents?: true

Size: 846 Bytes

Versions: 24

Compression:

Stored size: 846 Bytes

Contents

require_relative "model"

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

      optional_key(:associations, default: {})

      alias entity_manifest model_manifest

      def has_associations?
        associations && !associations.empty?
      end

      def primary_key_name
        primary_key_attribute.to_s
      end

      def primary_key_type
        @primary_key_type ||= TypeDeclaration.new(root_manifest, [*path, :primary_key_type])
      end

      def attribute_names
        super - [primary_key_name]
      end

      def full_entity_name
        full_model_name
      end

      def associations
        @associations ||= self[:associations].to_h do |path_key, type_name|
          [path_key.to_sym, Type.new(root_manifest, [:type, type_name])]
        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/entity.rb
foobara-0.0.25 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.24 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.23 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.22 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.21 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.20 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.19 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.18 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.17 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.16 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.15 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.14 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.13 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.12 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.11 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.10 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.9 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.8 projects/manifest/src/foobara/manifest/entity.rb
foobara-0.0.7 projects/manifest/src/foobara/manifest/entity.rb