Sha256: c8ed79fd2d905c11eefa2f0c88307698a22c83cdee21be2244bb233f4c66693c

Contents?: true

Size: 682 Bytes

Versions: 27

Compression:

Stored size: 682 Bytes

Contents

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

        module ClassMethods
          def entity_type
            model_type
          end

          def type_declaration(...)
            raise "No primary key set yet" unless primary_key_attribute

            super.merge(type: :entity, primary_key: primary_key_attribute)
          end

          def set_model_type
            if primary_key_attribute
              super
            end
          end

          def primary_key_type
            @primary_key_type ||= attributes_type.element_types[primary_key_attribute]
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/entity/src/concerns/types.rb
foobara-0.0.6 projects/entity/src/concerns/types.rb
foobara-0.0.5 projects/entity/src/concerns/types.rb
foobara-0.0.4 projects/entity/src/concerns/types.rb
foobara-0.0.3 projects/entity/src/concerns/types.rb
foobara-0.0.2 projects/entity/src/concerns/types.rb
foobara-0.0.1 projects/entity/src/concerns/types.rb