Sha256: 1a8539225eb3ba76960bcdfbb14d71da6222c4112d7164a3ee0b1b062a70b9a0

Contents?: true

Size: 907 Bytes

Versions: 8

Compression:

Stored size: 907 Bytes

Contents

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

        foobara_delegate :full_entity_name, :entity_name, to: :class

        module ClassMethods
          def entity_type
            model_type
          end

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

            super.merge(type: :detached_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

          def full_entity_name
            full_model_name
          end

          def entity_name
            model_name
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foobara-0.0.38 projects/detached_entity/src/concerns/types.rb
foobara-0.0.37 projects/detached_entity/src/concerns/types.rb
foobara-0.0.36 projects/detached_entity/src/concerns/types.rb
foobara-0.0.35 projects/detached_entity/src/concerns/types.rb
foobara-0.0.34 projects/detached_entity/src/concerns/types.rb
foobara-0.0.33 projects/detached_entity/src/concerns/types.rb
foobara-0.0.32 projects/detached_entity/src/concerns/types.rb
foobara-0.0.31 projects/detached_entity/src/concerns/types.rb